题解 | #合并表记录#

合并表记录

https://www.nowcoder.com/practice/de044e89123f4a7482bd2b214a685201

#include <iostream>
using namespace std;
#include <map>

int main() {
    //使用有序关联容器,其中的值不能重复, map来实现
    map<int, int>  word_count;
    int N = 0;
    cin >> N;
    for (int i = 0; i<N; i++)
    {
        int a,b;
        cin>>a>>b;
        word_count[a] +=b;
    }
    for(auto w: word_count)
    {
        cout<<w.first <<' '<< w.second << endl;
    }
    return 0;

    }

// 64 位输出请用 printf("%lld")

全部评论

相关推荐

抱抱碍事梨a:三点建议,第一点是建议再做一个项目,把自我介绍部分顶了,第二点是中南大学加黑加粗,第三点是建议加v详细交流
点赞 评论 收藏
分享
完美的潜伏者许愿简历通过:我上表jd,请求封我做后端大将军的事,北京有消息了:竟然不许!!! 他们一定是看我没有实习,这才故意驳回我的请求!
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务