# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
674927 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |