# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844222 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 2 ms | 492 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;
int main() {
int N;
cin >> N;
int total = 0;
vector<int> T(N), Z(N);
for (int i = 0;i < N; ++i) {
cin >> T[i] >> Z[i];
total += T[i];
}
vector<int> idx(N);
iota(idx.begin(), idx.end(), 0);
sort(idx.begin(), idx.end(), [&](int i, int j) { return Z[i] > Z[j]; });
vector<int> ans(N);
for (int i = 0;i < N; ++i) {
int j = idx[i];
ans[j] = min(total, Z[j]);
if (total < Z[j]) {
break;
}
total -= Z[j];
}
cout << count(ans.begin(), ans.end(), 0) << endl;
for (int i = 0;i < N; ++i) {
cout << ans[i] << ' ';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |