Submission #952562

# Submission time Handle Problem Language Result Execution time Memory
952562 2024-03-24T08:55:33 Z Sundavar Global Warming (CEOI18_glo) C++14
100 / 100
104 ms 5484 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,d;
    cin>>n>>d;
    vector<int> v(n);
    for(int& a : v) cin>>a;
    vector<int> smallest(n+1, 1e9+7), here(n);
    smallest[0] = 0;
    for(int i = 0; i < n; i++){
        int l = lower_bound(smallest.begin(), smallest.end(), v[i]) - smallest.begin();
        here[i] = l;
        smallest[l] = v[i];
    }
    vector<int> biggest(n+1, -(1e9+7));
    biggest[0] = 1e9+7;
    int sol = 0;
    for(int i = n-1; i >= 0; i--){
        int l = 0, r = n;
        while(r-l > 1)
            if(biggest[(r+l)/2] > v[i]-d) l = (l+r)/2;
            else r = (l+r)/2;
        sol = max(sol, l+here[i]);
        l = 0, r = n;
        while(r-l > 1)
            if(biggest[(r+l)/2] > v[i]) l = (l+r)/2;
            else r = (l+r)/2;
        biggest[l+1] = v[i];
    }
    cout << sol << "\n";
}
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 3556 KB Output is correct
2 Correct 91 ms 3544 KB Output is correct
3 Correct 100 ms 3556 KB Output is correct
4 Correct 92 ms 3548 KB Output is correct
5 Correct 78 ms 3504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1160 KB Output is correct
2 Correct 23 ms 1116 KB Output is correct
3 Correct 22 ms 1312 KB Output is correct
4 Correct 18 ms 1152 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 17 ms 1116 KB Output is correct
7 Correct 26 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 1816 KB Output is correct
2 Correct 49 ms 1860 KB Output is correct
3 Correct 99 ms 3408 KB Output is correct
4 Correct 75 ms 3520 KB Output is correct
5 Correct 38 ms 2424 KB Output is correct
6 Correct 74 ms 4592 KB Output is correct
7 Correct 90 ms 5116 KB Output is correct
8 Correct 49 ms 2908 KB Output is correct
# Verdict Execution time Memory 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 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 0 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 94 ms 3556 KB Output is correct
28 Correct 91 ms 3544 KB Output is correct
29 Correct 100 ms 3556 KB Output is correct
30 Correct 92 ms 3548 KB Output is correct
31 Correct 78 ms 3504 KB Output is correct
32 Correct 24 ms 1160 KB Output is correct
33 Correct 23 ms 1116 KB Output is correct
34 Correct 22 ms 1312 KB Output is correct
35 Correct 18 ms 1152 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 17 ms 1116 KB Output is correct
38 Correct 26 ms 1112 KB Output is correct
39 Correct 45 ms 1816 KB Output is correct
40 Correct 49 ms 1860 KB Output is correct
41 Correct 99 ms 3408 KB Output is correct
42 Correct 75 ms 3520 KB Output is correct
43 Correct 38 ms 2424 KB Output is correct
44 Correct 74 ms 4592 KB Output is correct
45 Correct 90 ms 5116 KB Output is correct
46 Correct 49 ms 2908 KB Output is correct
47 Correct 46 ms 2744 KB Output is correct
48 Correct 48 ms 2900 KB Output is correct
49 Correct 98 ms 5484 KB Output is correct
50 Correct 74 ms 4692 KB Output is correct
51 Correct 59 ms 3668 KB Output is correct
52 Correct 76 ms 4828 KB Output is correct
53 Correct 76 ms 4692 KB Output is correct
54 Correct 104 ms 5456 KB Output is correct
55 Correct 91 ms 5424 KB Output is correct