Submission #554343

#TimeUsernameProblemLanguageResultExecution timeMemory
554343PLMLPod starim krovovima (COCI20_psk)C++14
44 / 50
1 ms304 KiB
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ vector<int> a; int n,i = 0,t,z,cnt = 0;cin >> n; for(int i = 0;i<n;i++){ cin >> t >> z; cnt += t; a.push_back(z); } sort(a.begin(),a.end(),greater<int>()); while(cnt>0) cnt -= a[i++]; cout << n - i << endl; for(int j = 0;j<i-1;j++) cout << a[j] << " "; cout << cnt + a[i-1] << " "; for(int j = i;j<n;j++) cout << 0 << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...