Submission #593001

# Submission time Handle Problem Language Result Execution time Memory
593001 2022-07-10T06:01:25 Z zeroesandones Simple game (IZhO17_game) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define all(x) (x).begin(), (x).end()

#define sc second
#define fr first
#define pb push_back

void solve()
{
    int n, m;
    cin >> n >> m;

    int a[n];
    int mx = 0;
    FOR(i, 0, n) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }

    int lines[mx] = {};
    int sum[mx] = {};

    FOR(i, 1, n) {
        ++lines[min(a[i - 1], a[i]) + 1];
        --lines[max(a[i - 1], a[i])];
    }

    sum[0] = lines[0];
    FOR(i, 1, mx) {
        sum[i] = sum[i - 1] + lines[i];
    }
    FOR(i, 0, m) {
        int x, h;
        cin >> x >> h;
        cout << sum[h] << nl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -