QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#874838#9370. Gambling on Choosing RegionalsrlaaaRE 2ms20668kbC++231.5kb2025-01-28 18:01:152025-01-28 18:01:16

Judging History

This is the latest submission verdict.

  • [2025-01-28 18:01:16]
  • Judged
  • Verdict: RE
  • Time: 2ms
  • Memory: 20668kb
  • [2025-01-28 18:01:15]
  • Submitted

answer

#include<bits/stdc++.h>
using  namespace  std;
typedef long long ll;
vector <ll> se[15];
unordered_map <string,int> mp;
ll a[500010];
string team[500010];

int find(int x,ll p){
    int l=0,r=se[x].size()-1,mid;
    while(l<=r){
        if(l==r){
            if(se[x][l]>p) return se[x].size()-l;
            else return 0;
        }
        mid=(l+r)>>1;
        if(se[x][mid]>p) r=mid;
        else l=mid+1;
    }
}

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= ;
      // int co=se[no].end()-upper_bound(se[no].begin(),se[no].end(),a[i]);
      int co=find(no,a[i]);
       if(co>=mk-1) rank+=mk;
       else rank+=(co+1);

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

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 20656kb

input:

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

output:

2
1
2
2
1

result:

ok 5 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 20668kb

input:

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

output:

4
2
4
3
1

result:

ok 5 lines

Test #3:

score: -100
Runtime Error

input:

100000 100000
57148 51001 13357 71125 98369 67226 49388 90852 66291 39573 38165 97007 15545 51437 89611 41523 27799 15529 16434 44291 47134 90227 26873 52252 41605 21269 9135 55784 70744 17563 79061 73981 70529 35681 91073 52031 23811 79501 1607 46365 76868 72137 71041 29217 96749 46417 40199 55907 ...

output:


result: