Submission #890169

#TimeUsernameProblemLanguageResultExecution timeMemory
890169HADI_TPod starim krovovima (COCI20_psk)C++14
50 / 50
2 ms604 KiB
#include<bits/stdc++.h> #define int long long #define pb(x) push_back(x) #define in(x) insert(x) #define F first #define S second #define endl '\n' #define yes cout<<"YES"<<endl; #define no cout<<"NO"<<endl; const int M=1e9+7; const int N=2e5+10; using namespace std; int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n; cin>>n; int sum = 0; int ans[n+10]={0}; pair<int,int>a[n+10]; for(int i=1;i<=n;i++) { int x,y; cin>>x>>y; sum += x; a[i]={y,i}; } sort(a+1,a+1+n); for(int i = n;i>=1;i--) { int ad = min(sum , a[i].F); ans[a[i].S] += ad; sum -= ad; } int cnt = 0; for(int i=1;i<=n;i++) { if(ans[i] == 0) cnt++; } cout<<cnt<<endl; for(int i=1;i<=n;i++) cout<<ans[i]<<' '; cout<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...