QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#874850 | #9370. Gambling on Choosing Regionals | rlaaa | RE | 0ms | 0kb | C++23 | 1.5kb | 2025-01-28 18:09:31 | 2025-01-28 18:09:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector <ll> se[100010];
unordered_map <string,int> mp;
ll a[100010];
vector <string> team(100010);
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=1e9+10;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
5 3 1 2 3 100 THU 110 PKU 95 PKU 105 THU 115 PKU