# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
844273 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++17 | 1 ms | 348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
#define N 1005
using namespace std;
vector <pair<int, int> > glass(N);
vector <int> ans(N);
int32_t main(){
fast
int n;
cin>>n;
int all = 0;
for(int i = 0; i < n; i++) {
int amount;
glass[i].second = i;
cin>>amount>>glass[i].first;
all += amount;
}
sort(glass.begin(), glass.end());
reverse(glass.begin(), glass.end());
int fans;
for(int i = 0; i < n; i++) {
if(all <= 0) {fans = 0; break; };
ans[glass[i].second] = min(glass[i].first, all);
all -= glass[i].first;
if(all <= 0) {
fans = n - i - 1;
break;
}
}
cout<<fans<<"\n";
for(int i = 0; i < n; i++) {
cout<<ans[i]<<" ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |