Submission #1099596

#TimeUsernameProblemLanguageResultExecution timeMemory
1099596PetrixPod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms348 KiB
#include <iostream> #include <algorithm> using namespace std; #define int long long int rasp[1001]; struct pahar{ int a,ind; } v[1001]; bool cmp(pahar a,pahar b){ return a.a>b.a; } signed main() { int i,a,n,sum=0,cnt=0; cin>>n; for(i=1;i<=n;i++){ cin>>a>>v[i].a; v[i].ind=i;sum+=a; } sort(v+1,v+n+1,cmp); for(i=1;i<=n;i++){ if(sum){ rasp[v[i].ind]=min(sum,v[i].a); sum-=min(sum,v[i].a); }else cnt++; } cout<<cnt<<"\n"; for(i=1;i<=n;i++) cout<<rasp[i]<<" "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...