| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 543952 | AlperenT | Pod starim krovovima (COCI20_psk) | C++17 | 3 ms | 356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1000 + 5;
int n, ans[N];
struct Item{
int cur, total, i;
bool operator < (const Item &sc) const{
return array<int, 3>{total, cur, i} < array<int, 3>{sc.total, sc.cur, sc.i};
}
};
Item arr[N];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++){
cin >> arr[i].cur >> arr[i].total;
arr[i].i = i;
}
sort(arr + 1, arr + n + 1);
for(int i = 1; i <= n; i++){
for(int j = i + 1; j <= n; j++){
int tmp = min(arr[i].cur, arr[j].total - arr[j].cur);
arr[i].cur -= tmp, arr[j].cur += tmp;
}
}
for(int i = 1; i <= n; i++) ans[arr[i].i] = arr[i].cur;
cout << count(ans + 1, ans + n + 1, 0) << "\n";
for(int i = 1; i <= n; i++) cout << ans[i] << " ";
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
