# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
231813 | CodeTiger927 | Pod starim krovovima (COCI20_psk) | C++14 | 6 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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... |