# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
793563 | duyanhloveav | Growing Trees (BOI11_grow) | C++17 | 1083 ms | 3336 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define int long long
const int N = 9 + 1e5;
const int oo = 7 + 1e9;
int a[N];
void SaKaTa() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
sort (a + 1, a + 1 + n);
while (m--) {
char c;
int l, r;
cin >> c >> l >> r;
if (c == 'F') {
int pos = lower_bound(a + 1, a + 1 + n, r) - a;
if (pos != (n + 1)) {
for (int i = pos; i <= n; i++) {
a[i]++;
l--;
if (l == 0) break;
}
sort (a + 1, a + 1 + n);
}
} else {
int pos = lower_bound(a + 1, a + 1 + n, l) - a;
if (pos != (n + 1) && a[pos] <= r) {
int pos_two = upper_bound(a + 1, a + 1 + n, r) - a - 1;
cout << pos_two - pos + 1 << '\n';
} else cout << 0 << '\n';
}
}
}
int32_t main() {
#define TASKNAME "TREE"
cin.tie(0)->sync_with_stdio(0);
if ( fopen( TASKNAME".inp", "r" ) ) {
freopen (TASKNAME".inp", "r", stdin);
freopen (TASKNAME".out", "w", stdout);
}
int testcase = 1;
// scanf("%d", &testcase);
while (testcase--)
SaKaTa();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |