# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1273479 | SmuggingSpun | Pod starim krovovima (COCI20_psk) | C++20 | 1 ms | 572 KiB |
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n;
cin >> n;
vector<int>t(n);
ll Z = 0;
for(int i = 0; i < n; i++){
int z;
cin >> z >> t[i];
Z += z;
}
vector<int>p(n);
iota(p.begin(), p.end(), 0);
sort(p.begin(), p.end(), [&] (int i, int j){
return t[i] > t[j];
});
for(int i = 0; i < n; i++){
if(Z <= t[p[i]]){
t[p[i]] = Z;
cout << n - i - 1 << "\n";
for(int j = i + 1; j < n; j++){
t[p[j]] = 0;
}
break;
}
Z -= t[p[i]];
}
for(int& x : t){
cout << x << " ";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |