QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#661452 | #9422. Two-star Contest | wangxiaorui# | WA | 34ms | 18296kb | C++14 | 1.8kb | 2024-10-20 16:18:01 | 2024-10-20 16:18:06 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define F(x,y,z) for(int x=(y);x<=(z);x++)
using namespace std;
const int N=4e5+10;
int n,m,k;
int vid[N];
struct node{
int s;
int id;
vector <int> v;
}a[N];
int cnt[N];
bool cmp(node x,node y){
return x.s>y.s;
}
map <int,int> mp;
void solve(){
mp.clear();
cin>>n>>m>>k;
for(int i=1;i<=n;i++){
cnt[i]=0;
a[i].v.clear();
}
int u;
for(int i=1;i<=n;i++){
cin>>a[i].s;
a[i].id=i;
for(int j=1;j<=m;j++){
cin>>u;
a[i].v.push_back(u);
}
}
sort(a+1,a+1+n,cmp);
a[0].s=-1;
ll sum=0,minn,lstmax=1e18,totmax=1e18;
for(int i=1;i<=n;i++){
vid[a[i].id]=i;
sum=0;minn=0;
for(auto y:a[i].v){
if(y!=-1) sum+=y,minn+=y,cnt[i]+=y;
else sum+=k;
}
if(minn>=lstmax){
cout<<"No"<<endl;
return;
}
totmax=min(totmax,min(lstmax-1,sum));
if(a[i].s!=a[i-1].s){
mp[a[i].s]=totmax;
lstmax=totmax,totmax=1e18;
// cout<<a[i].s<<' '<<mp[a[i].s]<<endl;
}
}
cout<<"Yes"<<endl;
for(int i=1;i<=n;i++){
int id=vid[i];
int rest=mp[a[id].s];
rest-=cnt[id];
for(auto y:a[id].v){
if(y!=-1) cout<<y<<' ';
else{
if(rest<=0) cout<<0<<' ';
else
if(rest>=k){
cout<<k<<' ';
rest-=k;
}
else{
cout<<rest<<' ';
rest=0;
}
}
}
cout<<endl;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int T;
cin>>T;
while(T--) solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 18128kb
input:
5 3 4 5 5 1 3 -1 -1 2 -1 5 -1 5 3 3 -1 -1 4 2 3 10 10000 5 0 -1 1 10 10 10 2 3 10 10 1 2 3 100 4 5 6 2 3 10 100 1 2 3 10 4 5 6 2 3 10000 100 -1 -1 -1 1 -1 -1 -1
output:
Yes 1 3 5 5 2 5 0 5 3 5 1 4 No Yes 1 2 3 4 5 6 No Yes 10000 10000 10000 10000 10000 9999
result:
ok ok 5 cases (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 34ms
memory: 18296kb
input:
1013 3 2 1 1 -1 -1 2 0 1 3 -1 -1 4 8 96295 302790137 -1 849 -1 -1 33907 7926 9461 70117 695984050 -1 -1 56792 -1 -1 -1 19527 -1 302790137 12828 30553 40825 67577 91517 77952 55631 63781 302790137 29385 -1 -1 -1 750 -1 -1 -1 2 6 72716304 892657961 -1 -1 66436933 -1 45419040 55642613 892657961 -1 6271...
output:
Yes 0 0 0 1 1 1 No Yes 72716304 72716304 66436933 72716304 45419040 55642613 72716304 62712753 72716304 21765515 56544945 12385026 Yes 975402536 649527792 0 0 0 0 0 0 0 0 0 0 0 211610436 944794448 0 0 0 788675016 424172233 162632689 465907153 203583296 0 372435832 0 881228559 397814730 46523...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 2)