Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

水题,却搞了这么久,还是STL不清楚啊,map

Posted by 10041112acmer at 2013-08-17 19:31:30 on Problem 2153
RT
#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <map>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
const int N = 10010;
int main()
{
    int n;
    while(scanf("%d",&n) != EOF)
    {
        string ss;
        getchar();
        map<string,int> mp;
        map<string,int> :: iterator it;
        for(int i = 0; i < n; ++i)
        {
            getline(cin,ss);
            mp[ss] = 0;
        }
        int m;
        scanf("%d", &m);
        getchar();
        for(int i = 0; i < m; ++i)
        {
            int value = 0,score = 0;
            for(int j = 0; j < n; ++j)
            {
                scanf("%d",&score);
                getchar();
                getline(cin,ss);
                mp[ss] += score;
                if(ss == "Li Ming")
                    value = mp[ss];
            }
            int cnt = 0,num[N];
            for(it = mp.begin(); it != mp.end(); ++it)
                num[cnt++] = it -> second;
            int ans = 0;
            for(int k = 0; k < cnt; ++k)
            {
                if(num[k] > value)
                    ans++;
            }
            ans++;
            printf("%d\n", ans);
        }
    }
    return 0;

}


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator