답안 #500253

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500253 2021-12-30T14:23:04 Z Mounir Pod starim krovovima (COCI20_psk) C++14
40 / 50
2 ms 300 KB
#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);
      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;   
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 292 KB Output is correct
3 Correct 0 ms 292 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 292 KB Output is correct
8 Correct 2 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Incorrect 1 ms 300 KB Output isn't correct