Submission #1017185

#TimeUsernameProblemLanguageResultExecution timeMemory
1017185vjudge1Pod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms432 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int const N=2e5+5; int const mod=1e9+7; signed main(){ int n; cin>>n; vector<pair<int,int>> gla; int li=0; for (int i = 0; i < n; ++i) { int a; cin>>a; li+=a; cin>>a; gla.push_back({a,i}); } sort(gla.begin(), gla.end()); reverse(gla.begin(), gla.end()); int ans[n]={0}; int c=0; for(auto [v,i]:gla){ ans[i]=min(v,li); if(ans[i]==0) c++; li-=min(v,li); } cout<<c<<endl; for (int i = 0; i < n; ++i) cout<<ans[i]<<' '; cout<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...