답안 #1072799

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1072799 2024-08-24T05:05:11 Z HappyCapybara Global Warming (CEOI18_glo) C++17
25 / 100
2000 ms 5836 KB
#include<bits/stdc++.h>
using namespace std;

int n;
vector<int> st;

void update(int pos, int val, int node=1, int tl=0, int tr=n-1){
    if (tl == tr){
        st[node] = val;
        return;
    }
    int tm = (tl+tr)/2;
    if (pos <= tm) update(pos, val, node*2, tl, tm);
    else update(pos, val, node*2+1, tm+1, tr);
    st[node] = max(st[node*2], st[node*2+1]);
}

int query(int l, int r, int node=1, int tl=0, int tr=n-1){
    if (l <= tl && tr <= r) return st[node];
    int tm = (tl+tr)/2;
    int res = 0;
    if (l <= tm) res = max(res, query(l, r, node*2, tl, tm));
    if (tm+1 <= r) res = max(res, query(l, r, node*2+1, tm+1, tr));
    return res;
}

int main(){
    int x;
    cin >> n >> x;
    vector<int> v(n);
    for (int i=0; i<n; i++) cin >> v[i];
    st.resize(4*n, 0);

    vector<pair<int,int>> p(n);
    for (int i=0; i<n; i++) p[i] = {v[i], -i};

    sort(p.begin(), p.end());

    for (int i=n-1; i>=0; i--){
        int j = -p[i].second;
        int bsf = query(j, n-1);
        update(j, bsf+1);
    }

    int res = st[1];

    if (x == 0){
        cout << res << "\n";
        return 0;
    }

    for (int i=0; i<n; i++){
        for (int j=i; j<n; j++){
            for (int k=-x; k<=x; k+=2*x){
                if (k == 0) continue;
                for (int l=0; l<n; l++){
                    if (i <= l && l <= j) p[l] = {v[l]+k, -l};
                    else p[l] = {v[l], -l};
                }
                sort(p.begin(), p.end());
                for (int l=0; l<4*n; l++) st[l] = 0;
                for (int l=n-1; l>=0; l--){
                    int m = -p[l].second;
                    int bsf = query(m, n-1);
                    update(m, bsf+1);
                }
                res = max(res, st[1]);
            }
        }
    }

    cout << res << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 9 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 8 ms 348 KB Output is correct
15 Correct 7 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 9 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 8 ms 348 KB Output is correct
15 Correct 7 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Execution timed out 2071 ms 348 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 5716 KB Output is correct
2 Correct 118 ms 5712 KB Output is correct
3 Correct 119 ms 5836 KB Output is correct
4 Correct 128 ms 5828 KB Output is correct
5 Correct 85 ms 5832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2025 ms 1624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 3152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 9 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 8 ms 348 KB Output is correct
15 Correct 7 ms 348 KB Output is correct
16 Correct 8 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Execution timed out 2071 ms 348 KB Time limit exceeded
20 Halted 0 ms 0 KB -