Submission #856416

#TimeUsernameProblemLanguageResultExecution timeMemory
856416HiepVu217Growing Trees (BOI11_grow)C++17
40 / 100
1077 ms3124 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 17; int n, m, x, y, z, zz, a[N]; char t; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; } sort (a + 1, a + n + 1); while (m--) { cin >> t >> x >> y; if (t == 'F') { int i = 1; while (x > 0 && i <= n) { z = lower_bound (a + i, a + n + 1, y) - a; zz = z; if (z > n) { break; } y = a[z]; z = upper_bound (a + i, a + n + 1, y) - a - 1; i = z + 1; while (z >= max(0, zz) && x > 0) { a[z]++; z--; x--; } } } else { z = lower_bound (a + 1, a + n + 1, x) - a; zz = upper_bound (a + 1, a + n + 1, y) - a; cout << zz - z << "\n"; } } }
#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...