zoukankan      html  css  js  c++  java
  • nyoj----Course

     1  
     2 #include<stdio.h>
     3 #include<map>
     4 #include<string>
     5 #include<string.h>
     6 #include<algorithm>
     7 using namespace std;
     8 map<string,int> M;
     9 int main()
    10 {
    11     int n,m,i,score;
    12     char name[40];
    13     scanf("%d",&n);
    14     while(n--)
    15     {
    16         M.clear();
    17         int sum=0;
    18         scanf("%d",&m);
    19         getchar();
    20         for(i=0;i<m;i++)
    21         {
    22             scanf("%s%d",name,&score);
    23             if(!M.count(name))
    24             M[name]=score;
    25             else if(M[name]<score)
    26             {
    27                 M[name]=score;
    28                 sum++;
    29             }
    30         }
    31         printf("%d
    ",sum);
    32     }
    33 }
    34         
    View Code

    容器运用

    Course

    时间限制:1000 ms  |  内存限制:65535 KB
    难度:2
     
    描述
    There is such a policy in Sichuan University that if you are not satisfied with the score of your course, you can study this course again to get a better score. If you do this and get a higher score(than the highest score he got before), it can cover the original one. And we can say this time you update the score of this course successfully.
     
    Here is one schoolmate's all the courses he has studied and scores he got (sorted by chronological order). So could you tell me how many time he successfully update his scores of courses?
     
    输入
    The first of input is an integer T which stands for the number of test cases. For each test case the first line is an integer N (1 <= N <= 100) which stands for the number of courses he has studied.Then following N lines, each line contains a string (only contains letters and the length is no more than 30,which stands for the course name) and an integer (0<=integer<=100, which stands for the score of the course),separated by a space.

    Remember: the best way is getting the best score in one time.
    Study one course many times is not a recommended choice!
    输出
    For each test case output the number of times he update successfully.
    样例输入
    2
    6
    CProgramming 70
    DataStructrue 80
    CProgramming 80
    CProgramming 60
    CProgramming 90
    DataStructrue 70
    2
    CompilerTheory 95
    Network 90
    样例输出
    2
    0
  • 相关阅读:
    Go Map
    Go XORM
    Go切片
    Go函数
    dockerfile常用指令
    Goroutine并发控制
    Go 格式转换
    Go 常用知识点及实例
    Go 时间
    Go error
  • 原文地址:https://www.cnblogs.com/zsj-93/p/3149918.html
Copyright © 2011-2022 走看看