# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
440508 | MahfuzAhmed | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author: mahfuzz
* created: 02.07.2021
**/
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(p) p.begin(),p.end()
typedef long long ll;
bool cmp(pair<ll, ll> a, pair<ll, ll> b){
if(a.first > b.first)
return true;
return false;
}
int main(int argc, char* argv[]){
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
int n; cin >> n;
vector<pair<ll, ll>> vec;
ll sum = 0, arr[n];
for(int i = 0; i < n; i++){
ll x;
cin >> x >> arr[i];
sum += x;
vec.push_back({arr[i], 0});
}
sort(all(vec), cmp);
int cnt = 0;
for(int i = 0; i < n; i++){
vec[i].second = min(sum, vec[i].first);
sum -= vec[i].second;
if(vec[i].second == 0)
++cnt;
}
cout << cnt << "\n";
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(vec[j].first == arr[i]){
vec[j].first = -1;
cout << vec[j].second << " ";
break;
}
}
}
cout << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |