# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
731003 | 2023-04-26T18:27:39 Z | vjudge1 | Pod starim krovovima (COCI20_psk) | C++14 | 2 ms | 340 KB |
#include<iostream> #include<vector> #include<iomanip> #include<algorithm> #include<map> #include<set> #include<climits> #include<numeric> #include<queue> #include<unordered_map> #include<string> #include<climits> #include<unordered_set> #include<bitset> #include<cstring> #include<cmath> #include<stack> #if 1 #define pb push_back #define st first #define nd second #define endl '\n' #define fio ios_base::sync_with_stdio(false);cin.tie(NULL); #define MAXN ((int)(2e5+5)) #define int long long int using namespace std; const int inf = 1e17 + 5; #endif void fileio(string s){ #ifndef ONLINE_JUDGE freopen((s+string(".in")).c_str(),"r",stdin); freopen((s+string(".out")).c_str(),"w",stdout); #endif } signed main(){ //fileio("test"); //fio; int n; cin >> n; set<pair<int, int> , greater<pair<int, int> > >s; int sum = 0; for(int i = 0; i < n; ++i){ int t, z; cin >> t >> z; sum += t; s.insert({z,i}); } int status[n]; memset(status, 0, sizeof(status)); int ans = n; for(auto it = s.begin(); it != s.end(); ++it){ int val = (*it).st, idx = (*it).nd; if(val < sum){ sum -= val; status[idx] = val; ans--; } else{ status[idx] = sum; ans--; break; } } cout << ans << endl; for(int i = 0; i < n; ++i)cout << status[i] << ' ';cout << endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 300 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 300 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 2 ms | 340 KB | Output is correct |