# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440512 | colossal_pepe | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 204 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 <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define int long long
struct Glass {
int index, vol, cap;
};
int n, t, z, liquid = 0;
vector<Glass> glasses;
signed main() {
cin >> n;
glasses.resize(n);
for (int i = 0; i < n; i++) {
cin >> t >> z;
liquid += t;
glasses[i].index = i, glasses[i].vol = t, glasses[i].cap = z;
}
if (liquid > 0) {
sort(glasses.begin(), glasses.end(),
[](Glass g1, Glass g2) { return g1.cap > g2.cap; });
bool said = 0;
for (int i = 0; i < n; i++) {
int pour = min(glasses[i].cap, liquid);
glasses[i].vol = pour;
liquid -= pour;
if (liquid <= 0 and not said) {
cout << n - i - 1 << endl;
said = 1;
}
}
sort(glasses.begin(), glasses.end(),
[](Glass g1, Glass g2) { return g1.index < g2.index; });
} else {
cout << n << endl;
}
for (Glass g : glasses) {
cout << g.vol << ' ';
}
cout << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |