Submission #848472

# Submission time Handle Problem Language Result Execution time Memory
848472 2023-09-12T18:01:43 Z vjudge1 Growing Trees (BOI11_grow) C++17
40 / 100
1000 ms 3152 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;
                if (a[n] < y)
                {
                    break;
                }
                i = z + 1;
                //cout << z << "\n";
                while (z >= max(0, zz) && x > 0)
                {
                    a[z]++;
                    z--;
                    x--;
                }
                //for (int i = 1; i <= n; i++) cout << a[i] << " ";
                //cout << "\n";
            }
        }
        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 726 ms 2104 KB Output is correct
2 Execution timed out 1020 ms 1616 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 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 39 ms 1360 KB Output is correct
6 Correct 35 ms 1624 KB Output is correct
7 Correct 35 ms 344 KB Output is correct
8 Correct 15 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1624 KB Output is correct
2 Correct 306 ms 1848 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 18 ms 1404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 1872 KB Output is correct
2 Correct 43 ms 1620 KB Output is correct
3 Correct 220 ms 348 KB Output is correct
4 Correct 238 ms 1872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 1640 KB Output is correct
2 Correct 799 ms 2128 KB Output is correct
3 Correct 28 ms 860 KB Output is correct
4 Execution timed out 1016 ms 1112 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 170 ms 1840 KB Output is correct
2 Correct 707 ms 2292 KB Output is correct
3 Execution timed out 1040 ms 1112 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 125 ms 1716 KB Output is correct
2 Correct 740 ms 2128 KB Output is correct
3 Execution timed out 1049 ms 1616 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1029 ms 1524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 160 ms 2384 KB Output is correct
2 Execution timed out 1064 ms 2076 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 646 ms 3152 KB Output is correct