# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844329 | vjudge1 | Pod starim krovovima (COCI20_psk) | C++14 | 1 ms | 348 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.
#include <bits/stdc++.h>
#define int long long
using namespace std;
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> p){ return os << p.first << " " << p.second; }
void solve(void){
int x;
cin >> x;
vector<pair<int, int>> a(x);
vector<int> dolu(x), son(x,0);
int sum = 0;
for(int i=0; i<x; i++){
cin >> dolu[i];
sum += dolu[i];
cin >> a[i].first;
a[i].second = i;
}
sort(a.begin(), a.end(), [](pair<int,int> a, pair<int,int> b){ return a.first > b.first; } );
int ans = 0;
for(int i=0; i<x; i++){
if(a[i].first < sum){
sum -= a[i].first;
son[a[i].second] = a[i].first;
}else{
son[a[i].second] = sum;
sum -= sum;
ans += !son[a[i].second];
}
}
cout << ans << "\n";
for(auto gh: son)
cout << gh << " ";
cout << "\n";
}
signed main(){
int t=1;
// cin >> t;
while(t--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |