# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
500255 | Mounir | Pod starim krovovima (COCI20_psk) | C++14 | 2 ms | 204 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define x first
#define y second
#define int long long
using namespace std;
signed main(){
int nVals; cin >> nVals;
int sum = 0;
vector<pii> volumes;
for (int iVal = 0; iVal < nVals; ++iVal){
int cur, maxi; cin >> cur >> maxi;
sum += cur;
volumes.pb({maxi, iVal});
}
sort(all(volumes)); reverse(all(volumes));
int i = 0;
vector<int> quantites(nVals, 0);
while (i < nVals && sum > 0){
quantites[volumes[i].second] = min(volumes[i].first, sum);
sum -= volumes[i++].first;
}
cout << nVals - i << endl;
for (int quantite : quantites)
cout << quantite << " ";
cout << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |