zoukankan      html  css  js  c++  java
  • 湖南工业大学创新实验室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;
    }
    

      

  • 相关阅读:
    c#调用java
    Shell脚本之Crontab的格式
    windows安装的mysql中文乱码的坑
    要成为一个 Java 架构师得学习哪些知识?
    月薪 30K Java 程序员,需要掌握哪些技术?
    职场
    资源汇总
    SpringBoot布道系列 | 目录汇总 | 2019持续更新ing
    史上最简单的 SpringCloud 教程 | 终章
    SpringBoot 企业级核心技术学习专题
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/4996018.html
Copyright © 2011-2022 走看看