Submission #848466

# Submission time Handle Problem Language Result Execution time Memory
848466 2023-09-12T17:53:30 Z vjudge1 Growing Trees (BOI11_grow) C++17
0 / 100
3 ms 504 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);
    freopen ("gt.inp", "r", stdin);
    freopen ("gt.out", "w", stdout);
    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;
                if (z == n + 1)
                {
                    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 > 0 && a[z] >= y && 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";
        }
    }
}

Compilation message

grow.cpp: In function 'int main()':
grow.cpp:11:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen ("gt.inp", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
grow.cpp:12:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen ("gt.out", "w", stdout);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -