Submission #676142

#TimeUsernameProblemLanguageResultExecution timeMemory
676142esomerPod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl "\n" const int MOD = 998244353; void solve(){ int n; cin >> n; ll sum = 0; vector<pair<int, int>> v(n); for(int i = 0; i < n; i++){ int t, z; cin >> t >> z; sum += t; v[i] = {z, i}; } vector<int> ans(n, 0); sort(v.begin(), v.end()); int empty = n; for(int i = n - 1; i >= 0 && sum > 0; i--){ ll am = min((ll)v[i].first, sum); ans[v[i].second] = am; sum -= am; empty--; } cout << empty << endl; for(int x : ans) cout << x << " "; cout << endl; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); //freopen("inpt.txt", "r", stdin); //freopen("out.txt", "w", stdout); //int tt; cin >> tt; int tt = 1; for(int t = 1; t <= tt; t++){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...