Submission #1062757

#TimeUsernameProblemLanguageResultExecution timeMemory
1062757MasterMoonPod starim krovovima (COCI20_psk)C++17
44 / 50
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define __Master_Moon__ int main() struct hung { ll x,y; }; bool cmp(hung a,hung b) { return a.y > b.y; } void solve() { int n,ans = 0; cin >> n; hung a[n]; for(int i = 0;i < n;i++) cin >> a[i].x >> a[i].y; sort(a,a+n,cmp); for(int i = 0;i< n;i++) { for(int j = i + 1;j < n;j++) { if(a[i].x == a[i].y) break; if(a[i].x + a[j].x <= a[i].y) { a[i].x+=a[j].x; a[j].x = 0; } else { a[j].x-= (a[i].y-a[i].x); a[i].x=a[i].y; break; } } if(a[i].x == 0) ans++; } cout << ans << endl; for(int i = 0;i < n;i++) cout << a[i].x << " "; } __Master_Moon__ { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("o.inp","r",stdin); //freopen("o.out","w",stdout); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...