QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#874817#9370. Gambling on Choosing RegionalsrlaaaTL 0ms0kbC++231.3kb2025-01-28 17:22:462025-01-28 17:22:46

Judging History

This is the latest submission verdict.

  • [2025-01-28 17:22:46]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2025-01-28 17:22:46]
  • Submitted

answer

#include<bits/stdc++.h>
using  namespace  std;
typedef long long ll;
vector <ll> se[15];
unordered_map <string,int> mp;
ll a[100010];
string team[100010];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    freopen("..\\a.txt","r",stdin);
    int n,k,index=0;
    ll p,t,mk=1e13;
    string name;
    cin>>n>>k;
    while(k--) {
        cin>>t;
        mk=min(mk,t);
    }
    for(int i=1;i<=n;i++){
        cin>>p>>name;
        a[i]=p; team[i]=name;
        if(mp[name]==0){  //新的学校
            mp[name]=++index;
        }
        se[mp[name]].push_back(p);
    }
    for(int i=1;i<=index;i++) ranges::sort(se[i]);

    for(int i=1;i<=n;i++){
        int no=mp[team[i]],rank=0;
       auto it= upper_bound(se[no].begin(),se[no].end(),a[i]);
      // int co= distance(se[no].end(),it);
      int co=se[no].end()-it;
       if(co>=mk-1) rank+=mk;
       else rank+=(co+1);

       for(int j=1;j<=index;j++){
           if(j!=no){
               it=upper_bound(se[j].begin(),se[j].end(),a[i]);
              // co= distance(se[j].end(),it);
               co=se[j].end()-it;
               if(co>=mk) rank+=mk;
               else rank+=co;
           }
       }
       cout<<rank<<'\n';
    }
    return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

5 3
1 2 3
100 THU
110 PKU
95 PKU
105 THU
115 PKU

output:


result: