QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#586024 | #9370. Gambling on Choosing Regionals | kirco | TL | 380ms | 22928kb | C++23 | 1.5kb | 2024-09-24 00:03:20 | 2024-09-24 00:03:21 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define iosy ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
const int inf = 0x3f3f3f3f3f3f3f3fLL;
struct node{
int w;string s;int r;
};
bool cmp(node a,node b){
return a.w>b.w;
}
void solve(){
int n,k;cin>>n>>k;
vector<int> c(k+1);
int c1=inf;
for(int i=1;i<=k;i++){
cin>>c[i];
c1=min(c1,c[i]);
}
map<string,vector<int>> mp;
vector<node> a(n+1);
vector<int> b(n+1);
for(int i=1;i<=n;i++){
cin>>a[i].w>>a[i].s;
b[i]=a[i].w;
mp[a[i].s].push_back(a[i].w);
}
//排序校内排名
for(auto &[x,y]:mp){
sort(y.begin(),y.end());
}
// for(auto [x,y]:mp){
// cout<<x<<" ";
// for(auto x1:y){
// cout<<x1<<" ";
// }
// cout<<"\n";
// }
// cout<<"\n";
//预处理校内排名
for(int i=1;i<=n;i++){
int w=a[i].w;string s=a[i].s;
vector<int> t=mp[s];
int p=lower_bound(t.begin(),t.end(),w)-t.begin();
a[i].r=t.size()-p;
}
//排序总排名
sort(a.begin()+1,a.end(),cmp);
// for(int i=1;i<=n;i++){
// cout<<a[i].w<<" "<<a[i].s<<" "<<a[i].r<<"\n";
// }
//遍历计算
map<int,int> ans;
int sum=0;
for(int i=1;i<=n;i++){
int w=a[i].w,rank=a[i].r;
sum+=max((int)0,(min(c1,rank)-(rank-1)));//计算有误
//cout<<"sum="<<sum<<"\n";
ans[w]=sum;
}
for(int i=1;i<=n;i++){
cout<<ans[b[i]]<<"\n";
}
}
signed main()
{
iosy;
int _t=1;
//cin>>_t;
while(_t--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
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: 0ms
memory: 3568kb
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: 0
Accepted
time: 122ms
memory: 16996kb
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:
1000 999 1000 1000 1000 1000 1000 1000 1000 869 1000 958 1000 1000 1000 1000 999 1000 1000 1000 1000 1000 1000 990 1000 1000 1000 631 1000 1000 1000 956 1000 1000 1000 1000 1000 1000 575 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 993 1000 1000 999 1000 995 1000 1...
result:
ok 100000 lines
Test #4:
score: 0
Accepted
time: 380ms
memory: 16596kb
input:
100000 100000 67147 61000 23356 81124 108368 77225 59387 100851 76290 49572 48164 107006 25544 61436 99610 51522 37798 25528 26433 54290 57133 100226 36872 62251 51604 31268 19134 65783 80743 27562 89060 83980 80528 45680 101072 62030 33810 89500 11606 56364 86867 82136 81040 39216 106748 56416 5019...
output:
38094 68893 8008 72205 14144 6830 48242 54784 24827 22671 69968 63405 42977 34955 37074 72306 21663 58078 74211 68516 24344 37264 47307 18059 34775 56816 64113 72997 71482 13161 47439 48057 22609 73410 55895 53054 66205 5075 27380 71695 15008 61428 73978 50256 39523 68470 73731 20025 19546 73505 345...
result:
ok 100000 lines
Test #5:
score: 0
Accepted
time: 170ms
memory: 22928kb
input:
100000 100000 67147 61000 23356 81124 108368 77225 59387 100851 76290 49572 48164 107006 25544 61436 99610 51522 37798 25528 26433 54290 57133 100226 36872 62251 51604 31268 19134 65783 80743 27562 89060 83980 80528 45680 101072 62030 33810 89500 11606 56364 86867 82136 81040 39216 106748 56416 5019...
output:
26423 58937 26692 18521 54201 5354 99663 82451 25938 1683 19896 32088 3405 89911 19509 52739 19100 40454 5716 95198 37696 50581 75919 87382 10649 31531 40292 99554 7978 38455 31927 65170 12629 30610 12082 35639 9227 28959 27742 92620 7959 54392 13253 95233 13786 72724 30709 19341 63740 24682 66206 2...
result:
ok 100000 lines
Test #6:
score: 0
Accepted
time: 377ms
memory: 15896kb
input:
100000 1 57247 892690681 MWCYSYYCQP 688582181 QGHUMEAYLN 786575036 CXGGBWKFNQ 565413377 GXRPNRVYST 326676321 CXGGBWKFNQ 2384645 MWCYSYYCQP 590490190 IMKKASVWSR 988561901 EVIKEFFMZN 133742913 GXRPNRVYST 746788385 IMKKASVWSR 357437085 QGHUMEAYLN 873729521 MWCYSYYCQP 573297441 EVIKEFFMZN 671955105 SRTK...
output:
10732 31009 21255 43584 67241 99736 41027 1135 86570 25179 64139 12590 42769 32609 75833 56599 38288 37039 58315 58503 87788 27738 48076 69908 51542 37085 87819 43841 34588 42723 31619 32181 28755 57041 15301 4840 8344 13188 92864 45975 58723 57617 56869 4451 21644 16397 16133 3186 24829 76743 26538...
result:
ok 100000 lines
Test #7:
score: -100
Time Limit Exceeded
input:
100000 100000 67147 61000 23356 81124 108368 77225 59387 100851 76290 49572 48164 107006 25544 61436 99610 51522 37798 25528 26433 54290 57133 100226 36872 62251 51604 31268 19134 65783 80743 27562 89060 83980 80528 45680 101072 62030 33810 89500 11606 56364 86867 82136 81040 39216 106748 56416 5019...