Submission #390771

# Submission time Handle Problem Language Result Execution time Memory
390771 2021-04-16T21:30:00 Z SirCovidThe19th Global Warming (CEOI18_glo) C++14
100 / 100
130 ms 5352 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
	//days, max decrement
    int n, x;
    cin >> n >> x;
    int days[n];
    for (int i = 0; i < n; i++)
        cin >> days[i];
    
    int pref[n];
    int suff[n];

    int dp[n];
    fill(dp, dp+n, 1000000007);
    for (int i = 0; i < n; i++){
        int pos = lower_bound(dp, dp+n, days[i])-dp;
        dp[pos] = days[i];
        pref[i] = pos+1;
    }
    fill(dp, dp+n, 1000000007);
    for (int i = n-1; i >= 0; i--){
        int pos = lower_bound(dp, dp+n, -(days[i]-x))-dp;
        suff[i] = pos+1;
        pos = lower_bound(dp, dp+n, -days[i])-dp;
        dp[pos] = -days[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        ans = max(ans, pref[i]+suff[i]-1);
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 2 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 127 ms 5304 KB Output is correct
2 Correct 126 ms 5328 KB Output is correct
3 Correct 129 ms 5316 KB Output is correct
4 Correct 128 ms 5264 KB Output is correct
5 Correct 89 ms 4536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1456 KB Output is correct
2 Correct 33 ms 1516 KB Output is correct
3 Correct 31 ms 1464 KB Output is correct
4 Correct 22 ms 1248 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 22 ms 1356 KB Output is correct
7 Correct 30 ms 1460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 2764 KB Output is correct
2 Correct 58 ms 2704 KB Output is correct
3 Correct 119 ms 5312 KB Output is correct
4 Correct 92 ms 4456 KB Output is correct
5 Correct 44 ms 2404 KB Output is correct
6 Correct 120 ms 4368 KB Output is correct
7 Correct 107 ms 5040 KB Output is correct
8 Correct 56 ms 2724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 300 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 296 KB Output is correct
16 Correct 1 ms 296 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 2 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 2 ms 204 KB Output is correct
27 Correct 127 ms 5304 KB Output is correct
28 Correct 126 ms 5328 KB Output is correct
29 Correct 129 ms 5316 KB Output is correct
30 Correct 128 ms 5264 KB Output is correct
31 Correct 89 ms 4536 KB Output is correct
32 Correct 31 ms 1456 KB Output is correct
33 Correct 33 ms 1516 KB Output is correct
34 Correct 31 ms 1464 KB Output is correct
35 Correct 22 ms 1248 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 22 ms 1356 KB Output is correct
38 Correct 30 ms 1460 KB Output is correct
39 Correct 63 ms 2764 KB Output is correct
40 Correct 58 ms 2704 KB Output is correct
41 Correct 119 ms 5312 KB Output is correct
42 Correct 92 ms 4456 KB Output is correct
43 Correct 44 ms 2404 KB Output is correct
44 Correct 120 ms 4368 KB Output is correct
45 Correct 107 ms 5040 KB Output is correct
46 Correct 56 ms 2724 KB Output is correct
47 Correct 62 ms 2840 KB Output is correct
48 Correct 62 ms 2768 KB Output is correct
49 Correct 130 ms 5344 KB Output is correct
50 Correct 89 ms 4476 KB Output is correct
51 Correct 70 ms 3368 KB Output is correct
52 Correct 106 ms 4612 KB Output is correct
53 Correct 89 ms 4608 KB Output is correct
54 Correct 107 ms 5276 KB Output is correct
55 Correct 120 ms 5352 KB Output is correct