Submission #863399

#TimeUsernameProblemLanguageResultExecution timeMemory
863399vjudge1Pod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms460 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,avx2,fma") #include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define fi first #define se second #define pb push_back #define endl "\n" #define int long long using namespace std; typedef tuple<int, int, int> iii; typedef long long ll; const int mod =998244353; int n, sum; int t[1005], ans[1005]; pair<int, int> v[1005]; int32_t main(){ fast; cin>>n; for(int i=1;i<=n;i++){ cin>>t[i]>>v[i].fi; v[i].se=i; sum+=t[i]; } sort(v+1, v+n+1, greater<pair<int, int>>()); for(int i=1;i<=n;i++){ if(sum<=0){ cout<<n-i+1<<endl; break; } ans[v[i].se]=min(v[i].fi, sum); sum-=v[i].fi; } for(int i=1;i<=n;i++){ cout<<ans[i]<<" "; } cout<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...