QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#661459#9422. Two-star Contestwangxiaorui#WA 31ms23208kbC++141.8kb2024-10-20 16:20:492024-10-20 16:20:51

Judging History

你现在查看的是最新测评结果

  • [2024-10-20 16:20:51]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:23208kb
  • [2024-10-20 16:20:49]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define int 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,ll> 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];
        ll 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;
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int T;
    cin>>T;
    while(T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 22020kb

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: 31ms
memory: 23208kb

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)