QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#838127 | #9957. Doki Doki Literature Club | jiangzhihui# | AC ✓ | 2ms | 3608kb | C++14 | 858b | 2024-12-30 21:14:32 | 2024-12-30 21:14:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct node{
string s;
int w;
node(const string& s,const int& w):s(s),w(w){}
bool operator < (const node& o)const{
if(w==o.w)return s<o.s;
return w>o.w;
}
};
void solve(){
int n,m;
cin>>n>>m;
vector<node> a;
for(int i=0;i<n;i++){
string s;
int w;
cin>>s>>w;
a.push_back(node(s,w));
}
sort(a.begin(),a.end());
long long ans=0;
for(int i=0;i<m;i++){
ans+=1ll*a[i].w*(m-i);
}
cout<<ans<<" ";
for(int i=0;i<m;i++){
cout<<a[i].s;
if(i==m-1)cout<<'\n';
else cout<<' ';
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T;
cin>>T;
while(T--){
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
4 10 8 hello 0 world 0 behind 0 far 1 be 2 spring 10 can 15 comes 20 winter 25 if 200 5 5 collegiate 0 programming -5 zhejiang 10 provincial 5 contest -45 3 2 bcda 1 bcd 1 bbbbb 1 3 2 a 1 aa 1 aaa 1
output:
2018 if winter comes can spring be far behind 15 zhejiang provincial collegiate programming contest 3 bbbbb bcd 3 a aa
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
100 56 21 isbv 379374805 p 958281210 boupqzt -444708712 ddcbijoldb -708366273 orlj -735608531 skqz 583873140 uwpvp -81928722 utrymioazc 489698571 zg -314645172 nopvqe -922685632 h -832185466 ukhmmpuxcy 978983326 lcklkxzssr -772060370 bozlhttpl 675796877 go -340756288 gqvsd -858509938 rsgl 882170612 ...
output:
170699165603 ukhmmpuxcy pdxxts p rsgl vjl rqmidrt bozlhttpl thrqnyb oxmyrcjl xswmr fqrcwhsj wszkqyuj skqz wjfll utrymioazc zzqutjp vfv isbv iixdqetqfb qrlg pna 16261565367 gveijtg qzdfc fk majjarhxp qph p 4297864976 srggbdmdkr zterqtgui qsermzyhw 1385794435 gt dhatqi 60220088288 ylqkzp beiukvmjj bul...
result:
ok 100 lines
Extra Test:
score: 0
Extra Test Passed