답안 #232214

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
232214 2020-05-16T12:37:24 Z nicolaalexandra Global Warming (CEOI18_glo) C++14
100 / 100
163 ms 4216 KB
#include <bits/stdc++.h>
#define DIM 200010
using namespace std;
int v[DIM],d[DIM],dp_left[DIM],dp_right[DIM];
int n,i,x,k,sol;
int main (){

    //ifstream cin ("date.in");
    //ofstream cout ("date.out");

    cin>>n>>x;
    for (i=1;i<=n;i++)
        cin>>v[i];

    for (i=n;i;i--){
        int st = 1, dr = k;
        while (st <= dr){
            int mid = (st+dr)>>1;
            if (v[d[mid]] > v[i])
                st = mid+1;
            else dr = mid-1;
        }

        if (st == k+1)
            k++;
        d[st] = i;

        dp_right[i] = st;
    }

    /// modific un sufix

    k = 0;
    for (i=1;i<=n;i++){
        int st = 1, dr = k;
        while (st <= dr){
            int mid = (st+dr)>>1;
            if (v[d[mid]] < v[i])
                st = mid+1;
            else dr = mid-1;
        }

        if (st == k+1)
            k++;
        d[st] = i;

        if (i < n){

            int val = v[i+1] + x;
            /// vreau sa gasesc cea mai mare valoare mai mica decat asta
            int st = 1, dr = k, poz = 0;
            while (st <= dr){
                int mid = (st+dr)>>1;
                if (v[d[mid]] < val){
                    poz = mid;
                    st = mid+1;
                } else dr = mid-1;
            }

            sol = max (sol,dp_right[i+1] + poz);

        }
    }
    sol = max (sol,k);

    cout<<sol;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 1996 KB Output is correct
2 Correct 163 ms 1924 KB Output is correct
3 Correct 158 ms 1912 KB Output is correct
4 Correct 161 ms 1912 KB Output is correct
5 Correct 99 ms 2296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 736 KB Output is correct
2 Correct 43 ms 760 KB Output is correct
3 Correct 42 ms 760 KB Output is correct
4 Correct 28 ms 768 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 28 ms 768 KB Output is correct
7 Correct 41 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 1148 KB Output is correct
2 Correct 77 ms 1144 KB Output is correct
3 Correct 151 ms 1912 KB Output is correct
4 Correct 102 ms 2236 KB Output is correct
5 Correct 52 ms 1276 KB Output is correct
6 Correct 97 ms 2168 KB Output is correct
7 Correct 132 ms 2240 KB Output is correct
8 Correct 81 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 4 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 6 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 157 ms 1996 KB Output is correct
28 Correct 163 ms 1924 KB Output is correct
29 Correct 158 ms 1912 KB Output is correct
30 Correct 161 ms 1912 KB Output is correct
31 Correct 99 ms 2296 KB Output is correct
32 Correct 45 ms 736 KB Output is correct
33 Correct 43 ms 760 KB Output is correct
34 Correct 42 ms 760 KB Output is correct
35 Correct 28 ms 768 KB Output is correct
36 Correct 4 ms 256 KB Output is correct
37 Correct 28 ms 768 KB Output is correct
38 Correct 41 ms 760 KB Output is correct
39 Correct 80 ms 1148 KB Output is correct
40 Correct 77 ms 1144 KB Output is correct
41 Correct 151 ms 1912 KB Output is correct
42 Correct 102 ms 2236 KB Output is correct
43 Correct 52 ms 1276 KB Output is correct
44 Correct 97 ms 2168 KB Output is correct
45 Correct 132 ms 2240 KB Output is correct
46 Correct 81 ms 1144 KB Output is correct
47 Correct 94 ms 2040 KB Output is correct
48 Correct 82 ms 2040 KB Output is correct
49 Correct 161 ms 4088 KB Output is correct
50 Correct 101 ms 3448 KB Output is correct
51 Correct 79 ms 2808 KB Output is correct
52 Correct 107 ms 3576 KB Output is correct
53 Correct 106 ms 3576 KB Output is correct
54 Correct 136 ms 4216 KB Output is correct
55 Correct 149 ms 3832 KB Output is correct