Submission #856419

# Submission time Handle Problem Language Result Execution time Memory
856419 2023-10-03T12:27:59 Z HiepVu217 Growing Trees (BOI11_grow) C++17
40 / 100
1000 ms 1176 KB
#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 >= 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 707 ms 792 KB Output is correct
2 Execution timed out 1074 ms 796 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 348 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 39 ms 688 KB Output is correct
6 Correct 34 ms 660 KB Output is correct
7 Correct 38 ms 348 KB Output is correct
8 Correct 15 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 604 KB Output is correct
2 Correct 324 ms 936 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 18 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 860 KB Output is correct
2 Correct 44 ms 684 KB Output is correct
3 Correct 239 ms 468 KB Output is correct
4 Correct 252 ms 840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 852 KB Output is correct
2 Correct 810 ms 852 KB Output is correct
3 Correct 30 ms 592 KB Output is correct
4 Execution timed out 1068 ms 604 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 171 ms 848 KB Output is correct
2 Correct 723 ms 852 KB Output is correct
3 Execution timed out 1094 ms 600 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 840 KB Output is correct
2 Correct 716 ms 852 KB Output is correct
3 Execution timed out 1042 ms 604 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1034 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 149 ms 812 KB Output is correct
2 Execution timed out 1042 ms 1040 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 733 ms 1176 KB Output is correct