Submission #844407

#TimeUsernameProblemLanguageResultExecution timeMemory
844407vjudge1Pod starim krovovima (COCI20_psk)C++17
0 / 50
2 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" #define all(aa) aa.begin(), aa.end() int main(){ int n; cin>>n; vector<int> ans(n); vector<pair<int, int>> v(n); int s=0; for(int i=0; i<n; i++){ int a; cin>>a>>v[i].first; v[i].second=i; s+=a; } sort(all(v), greater<pair<int, int>>()); int i; for(i=0; i<n; i++){ if(s>=v[i].first){ ans[v[i].second]=v[i].first; s-=v[i].first; } else{ ans[i]=s; break; } } cout<<n-i+(s==0)<<endl; for(int j=0; j<n; j++) cout<<ans[j]<<' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...