Submission #844639

#TimeUsernameProblemLanguageResultExecution timeMemory
844639vjudge1Pod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ int N;cin>>N; ll m=0; vector<pair<ll,int>> Z; for(int i=0;i<N;i++){ ll t,x;cin>>t>>x; m+=t; Z.push_back(make_pair(x,i)); } sort(Z.begin(),Z.end(),greater<pair<ll,int>>()); ll p=0; vector<ll> ZR(N); for(int i=0;i<N;i++){ ZR[Z[i].second] = min(m,Z[i].first); m-=ZR[Z[i].second]; if(ZR[Z[i].second]==0){p++;} } cout<<p<<endl; for(auto &i:ZR)cout<<i<<" "; }
#Verdict Execution timeMemoryGrader output
Fetching results...