Submission #834786

#TimeUsernameProblemLanguageResultExecution timeMemory
834786mat_jurGrowing Trees (BOI11_grow)C++17
0 / 100
30 ms8428 KiB
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG auto&operator<<(auto &o, pair<auto, auto> p) {o << "(" << p.first << "," << p.second << ")"; return o;} auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";for(auto e:x)o<< e << ", ";return o<<"}";} #define debug(X) cerr << "["#X"]:" << X << '\n'; #else #define debug(X) ; #endif #define ll long long int main () { int n, q; cin >> n >> q; vector<int> cnt(1000000); for (int i = 0; i < n; i++) { int a; cin >> a; cnt[a]++; } while (q--) { char c; cin >> c; if (c == 'F') { int c, h; cin >> c >> h; int y = 0; while (c > 0) { int x = min(cnt[h], c); cnt[h] += y; cnt[h] -= x; y = x; c -= x; h++; } cnt[h] += y; } else { int res = 0; int l, r; cin >> l >> r; for (int i = l; i <= r; i++) { res += cnt[i]; } cout << res << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...