Submission #732231

#TimeUsernameProblemLanguageResultExecution timeMemory
732231vjudge1Pod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms368 KiB
#include<bits/stdc++.h> #define int long long #define MOD 1000000007 #define all(x) x.begin(),x.end() #define ff first #define ss second #define pb push_back #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); using namespace std; int32_t main(){ fast; int n; cin>>n; int a[n],b[n],s=0; vector<pair<int,int>>v; for(int i=0;i<n;i++){ cin>>a[i]>>b[i]; s+=a[i]; v.pb({b[i],i}); } sort(all(v)); int ans[n],cnt=0; for(int i=v.size()-1;i>=0;i--){ if(s==0)cnt++; ans[v[i].ss]=min(s,v[i].ff); s-=min(s,v[i].ff); } cout<<cnt<<endl; for(int i=0;i<n;i++)cout<<ans[i]<<" "; cout<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...