Submission #131683

# Submission time Handle Problem Language Result Execution time Memory
131683 2019-07-17T12:46:09 Z apostoldaniel854 Global Warming (CEOI18_glo) C++14
5 / 100
192 ms 3960 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5, INF = 2e9 + 7;
int nr;
int sol[1 + N], poz[1 + N], scm[1 + N];
int a[1 + N];
inline int get (int n, int orient) {
    int st, dr, p;
    st = 1; dr = nr;
    if (orient)
        p = nr + 1;
    else
        p = 0;
    while (st <= dr) {
        int mij = (st + dr) / 2;
        if ((sol[mij] > n && orient) || (sol[mij] < n && !orient)) {
            dr = mij - 1;
            p = mij;
        }
        else
            st = mij + 1;
    }
    return p;
}

int main() {
    int n, x;
    cin >> n >> x;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sol[1] = INF;
    nr = 1;
    for (int i = n; i > 0; i--) {
        if (a[i] < sol[nr]) {
            nr++;
            poz[i] = nr;
            sol[nr] = a[i];
        }
        else {
            int p = get (a[i], 0);
            sol[p] = a[i];
            poz[i] = p;
        }
    }
    sol[1] = 0;
    nr = 1;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int p;
        if (a[i] + x > sol[nr])
            p = nr + 1;
        else
            p = get (a[i], x + 1);
        //cout << p << "\n";
        ans = max (ans, poz[i] + p - 3);
        if (a[i] > sol[nr]) {
            nr++;
            sol[nr] = a[i];
        }
        else {
            int p = get (a[i], 1);
            sol[p] = a[i];
        }
    }
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 188 ms 2036 KB Output is correct
2 Correct 188 ms 1940 KB Output is correct
3 Correct 189 ms 1928 KB Output is correct
4 Correct 192 ms 1908 KB Output is correct
5 Incorrect 121 ms 2280 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 760 KB Output is correct
2 Correct 47 ms 732 KB Output is correct
3 Correct 48 ms 660 KB Output is correct
4 Incorrect 30 ms 760 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 88 ms 1196 KB Output is correct
2 Correct 89 ms 2188 KB Output is correct
3 Correct 176 ms 3960 KB Output is correct
4 Incorrect 111 ms 3384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 252 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Halted 0 ms 0 KB -