Submission #440503

#TimeUsernameProblemLanguageResultExecution timeMemory
440503colossal_pepePod starim krovovima (COCI20_psk)C++17
40 / 50
1 ms240 KiB
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct Glass { int index, vol, cap; }; int n, t, z, liquid = 0; vector<Glass> glasses; int 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 timeMemoryGrader output
Fetching results...