# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844257 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++98 | 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.
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
int main(){
int n, liq, *ans, index, ocount;
int64_t total;
pair<int, int> *glasses;
cin >> n;
glasses = new pair<int, int>[n];
for (int i = 0; i < n; i++){
cin >> liq;
total += liq;
cin >> glasses[i].first;
glasses[i].second = i;
}
std::sort(glasses, glasses + n);
ans = new int[n];
for (int i = 0; i < n; i++) ans[i] = 0;
index = n - 1;
ocount = n;
while (total > 0){
ocount--;
if (glasses[index].first > total){
ans[glasses[index].second] = total;
total = 0;
break;
}
ans[glasses[index].second] = glasses[index].first;
total -= glasses[index].first;
index--;
}
cout << ocount << endl;
for (int i = 0; i < n; i++){
cout << ans[i];
if (i != n - 1) cout << " ";
}
cout << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |