QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#874817 | #9370. Gambling on Choosing Regionals | rlaaa | TL | 0ms | 0kb | C++23 | 1.3kb | 2025-01-28 17:22:46 | 2025-01-28 17:22:46 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
5 3 1 2 3 100 THU 110 PKU 95 PKU 105 THU 115 PKU