Submission #844426

#TimeUsernameProblemLanguageResultExecution timeMemory
844426vjudge1Pod starim krovovima (COCI20_psk)C++17
50 / 50
1 ms348 KiB
// author: erray #include <bits/stdc++.h> #ifdef DEBUG #include "debug.h" #else #define debug(...) void(37) #endif using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<int> T(N), Z(N); long long tot = 0; for (int i = 0; i < N; ++i) { cin >> T[i] >> Z[i]; tot += T[i]; } vector<int> ord(N); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](int x, int y) { return Z[x] > Z[y]; }); int ans = 0; for (auto i : ord) { T[i] = min(0LL + Z[i], tot); tot -= T[i]; ans += (T[i] == 0); } cout << ans << '\n'; for (int i = 0; i < N; ++i) { cout << T[i] << " \n"[i == N - 1]; } }
#Verdict Execution timeMemoryGrader output
Fetching results...