Submission #844628

#TimeUsernameProblemLanguageResultExecution timeMemory
844628vjudge1Pod starim krovovima (COCI20_psk)C++17
36 / 50
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ int N;cin>>N; vector<ll> T(N),Z(N); for(int i=0;i<N;i++)cin>>T[i]>>Z[i]; ll m = accumulate(T.begin(),T.end(),0); sort(Z.begin(),Z.end(),greater<ll>()); bool flag = true; for(int i=0;i<N;i++){ ll dec = min(Z[i],m); Z[i]=dec; m-=dec; if(m==0 && flag){cout<<N-i-1<<endl;flag=false;} } for(auto &i:Z)cout<<i<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...