답안 #131685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
131685 2019-07-17T12:48:05 Z apostoldaniel854 Global Warming (CEOI18_glo) C++14
5 / 100
191 ms 2320 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] = -INF;
    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;
}
# 결과 실행 시간 메모리 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 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 -
# 결과 실행 시간 메모리 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 188 ms 1912 KB Output is correct
2 Correct 187 ms 2040 KB Output is correct
3 Correct 191 ms 2036 KB Output is correct
4 Correct 188 ms 1912 KB Output is correct
5 Incorrect 115 ms 2320 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 760 KB Output is correct
2 Correct 48 ms 760 KB Output is correct
3 Correct 47 ms 732 KB Output is correct
4 Incorrect 31 ms 760 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 1136 KB Output is correct
2 Correct 89 ms 1084 KB Output is correct
3 Correct 182 ms 2000 KB Output is correct
4 Incorrect 115 ms 2224 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 256 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 -