• 湖南工业大学创新实验室2015年新生赛(一)1009(重开)


    分数统计

    Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
    Total Submission(s) : 38   Accepted Submission(s) : 19

    Font: Times New Roman | Verdana | Georgia

    Font Size: ← →

    Problem Description

    双十二的问题处理完了, Ikids 学长又遇到了一个
    棘手的问题,现在Ikids学长有许多人员要统计他们
    的总分数, 需要你帮忙, Ikids 学长怕问题太过
    麻烦, 好心的把人员都编号了。

    Input

    输入包含多组输入

    输入 M , M 表示 M条记录
    每条记录包含两个整数,分别代表人的编号和分数
    M < 1000
    编号,分数 < 1e9 + 7;

    Output

    将所有被记录的人按照编号从小到大的方式
    输出他们的 编号, 分数。

    Sample Input

    5
    2 3
    3 2
    4 2
    2 1
    2 1

    Sample Output

    2 5
    3 2
    4 2

    Author

    Aoxuets
     
    map的简单用法
    #include<stdio.h>
    //#include<bits/stdc++.h>
    #include<string.h>
    #include<iostream>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<queue>
    #include<map>
    #include<vector>
    #include<algorithm>
    #include<limits.h>
    #define inf 0x3fffffff
    #define lson l,m,rt<<1
    #define rson m+1,r,rt<<1|1
    #define LL long long
    using namespace std;
    map<string,int>q;
    struct P
    {
        string s;
        int num;
    }hehe[10000];
    bool cmd(P x,P y)
    {
        if(x.s<y.s)
            return 1;
    
        return 0;
    }
    int main()
    {
       int t;
       int i;
       string s;
       int num;
       while(cin>>t)
       {
           for(i=0;i<t;i++)
           {
              cin>>hehe[i].s>>hehe[i].num;
              q[hehe[i].s]+=hehe[i].num;
           }
          // cout<<q.size()<<endl;
           map<string,int>::iterator it;
           for(it=q.begin();it!=q.end();it++)
           {
               cout<<it->first<<" "<<it->second<<endl;
           }
           q.clear();
       }
       return 0;
    }
    

      

  • 相关阅读:
    储存过程与触发器
    session 和 cookie
    (四)Jira工作流状态的属性
    (三)Jira scriptrunner插件
    (二)JIRA安装
    vs2015 调试无法访问网站的问题
    设计模式
    依赖倒置、反射、泛型、委托、AOP
    C# .NET
    持续集成
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/4996018.html
Copyright © 2020-2023  润新知