# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
231813 | CodeTiger927 | Pod starim krovovima (COCI20_psk) | C++14 | 6 ms | 384 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.
using namespace std;
#include <iostream>
#include <queue>
int N;
priority_queue<pair<long long,int>> pq;
int ans;
long long total = 0;
long long arr[1005];
int main() {
cin >> N;
ans = N;
for(int i = 0;i < N;i++) {
long long a,b;
cin >> a >> b;
pq.push({b,i});
total += a;
}
while(total > 0) {
ans--;
pair<long long,int> cur = pq.top();
pq.pop();
if(total > cur.first) {
arr[cur.second] = cur.first;
}else{
arr[cur.second] = total;
}
total -= cur.first;
}
cout << ans << endl;
for(int i = 0;i < N;i++) {
cout << arr[i] << " ";
}
cout << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |