#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 time |
Memory |
Grader output |
1 |
Correct |
698 ms |
2072 KB |
Output is correct |
2 |
Execution timed out |
1045 ms |
1528 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
476 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
476 KB |
Output is correct |
5 |
Correct |
38 ms |
1492 KB |
Output is correct |
6 |
Correct |
34 ms |
1616 KB |
Output is correct |
7 |
Correct |
35 ms |
344 KB |
Output is correct |
8 |
Correct |
15 ms |
1108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
1620 KB |
Output is correct |
2 |
Correct |
299 ms |
1816 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
18 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
1876 KB |
Output is correct |
2 |
Correct |
43 ms |
1616 KB |
Output is correct |
3 |
Correct |
212 ms |
600 KB |
Output is correct |
4 |
Correct |
229 ms |
1956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
1616 KB |
Output is correct |
2 |
Correct |
771 ms |
2128 KB |
Output is correct |
3 |
Correct |
28 ms |
860 KB |
Output is correct |
4 |
Execution timed out |
1022 ms |
1112 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
1872 KB |
Output is correct |
2 |
Correct |
677 ms |
2032 KB |
Output is correct |
3 |
Execution timed out |
1051 ms |
1116 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
129 ms |
1804 KB |
Output is correct |
2 |
Correct |
739 ms |
2308 KB |
Output is correct |
3 |
Execution timed out |
1077 ms |
1512 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1030 ms |
1368 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
2292 KB |
Output is correct |
2 |
Execution timed out |
1067 ms |
1804 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
640 ms |
3124 KB |
Output is correct |