#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;
if (a[n] < y)
{
break;
}
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 time |
Memory |
Grader output |
1 |
Correct |
760 ms |
852 KB |
Output is correct |
2 |
Execution timed out |
1045 ms |
604 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
39 ms |
604 KB |
Output is correct |
6 |
Correct |
34 ms |
764 KB |
Output is correct |
7 |
Correct |
34 ms |
348 KB |
Output is correct |
8 |
Correct |
15 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
856 KB |
Output is correct |
2 |
Correct |
303 ms |
748 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
18 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
912 KB |
Output is correct |
2 |
Correct |
43 ms |
804 KB |
Output is correct |
3 |
Correct |
224 ms |
468 KB |
Output is correct |
4 |
Correct |
231 ms |
592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
848 KB |
Output is correct |
2 |
Correct |
787 ms |
856 KB |
Output is correct |
3 |
Correct |
28 ms |
604 KB |
Output is correct |
4 |
Execution timed out |
1060 ms |
604 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
169 ms |
760 KB |
Output is correct |
2 |
Correct |
700 ms |
1120 KB |
Output is correct |
3 |
Execution timed out |
1038 ms |
604 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
952 KB |
Output is correct |
2 |
Correct |
756 ms |
1040 KB |
Output is correct |
3 |
Execution timed out |
1055 ms |
604 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1006 ms |
776 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
152 ms |
864 KB |
Output is correct |
2 |
Execution timed out |
1010 ms |
1056 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
647 ms |
1368 KB |
Output is correct |