QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#735771 | #9422. Two-star Contest | Ufowoqqqo | WA | 59ms | 3720kb | C++14 | 1.5kb | 2024-11-11 21:37:35 | 2024-11-11 21:37:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,m;
ll k;
cin>>n>>m>>k;
vector<int>s(n);
vector<vector<int>>p(n,vector<int>(m));
for(int i=0;i<n;i++)
{
cin>>s[i];
for(int j=0;j<m;j++)
cin>>p[i][j];
}
vector<int>id(n);
for(int i=0;i<n;i++)
id[i]=i;
sort(id.begin(),id.end(),[&](int x,int y){
return s[x]>s[y];
});
bool ok=true;
ll mx=1e18;
for(int j=0;j<n;j++)
{
int i=id[j];
ll sum=0,cnt=0;
for(int l=0;l<m;l++)
if(p[i][l]!=-1)sum+=p[i][l];
else cnt++;
if(sum>=mx)
{
ok=false;
break;
}
ll tar=min(mx-sum-1,cnt*k);
mx=sum+tar;
for(int l=0;l<m;l++)
{
if(p[i][l]!=-1)continue;
ll cur=min(tar,k);
p[i][l]=cur;
tar-=cur;
}
}
if(!ok)
{
cout<<"No"<<endl;
continue;
}
cout<<"Yes"<<endl;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cout<<p[i][j]<<" ";
cout<<endl;
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3612kb
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: 59ms
memory: 3720kb
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 975402536 975402536 975402536 975402536 975402536 67482408 0 0 975402536 975402536 975402536 975402536 211610436 944794448 67558026 0 0 788675016 42...
result:
wrong answer Participant fails to find an answer while the jury found one. (test case 2)