# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844426 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 348 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.
// author: erray
#include <bits/stdc++.h>
#ifdef DEBUG
#include "debug.h"
#else
#define debug(...) void(37)
#endif
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int N;
cin >> N;
vector<int> T(N), Z(N);
long long tot = 0;
for (int i = 0; i < N; ++i) {
cin >> T[i] >> Z[i];
tot += T[i];
}
vector<int> ord(N);
iota(ord.begin(), ord.end(), 0);
sort(ord.begin(), ord.end(), [&](int x, int y) {
return Z[x] > Z[y];
});
int ans = 0;
for (auto i : ord) {
T[i] = min(0LL + Z[i], tot);
tot -= T[i];
ans += (T[i] == 0);
}
cout << ans << '\n';
for (int i = 0; i < N; ++i) {
cout << T[i] << " \n"[i == N - 1];
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |