Submission #1105824

# Submission time Handle Problem Language Result Execution time Memory
1105824 2024-10-28T03:13:52 Z Articulation_points Global Warming (CEOI18_glo) C++14
100 / 100
43 ms 6776 KB
/* Dirty code by Articulation_points */
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int oo=2e18+1;
const int MAXN=2e5;
int n,k,a[MAXN+5],dp[MAXN+5],ans;
vector<int>v;
signed main(){
    cin.tie(0)->sync_with_stdio(false);
    cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;++i)
        cin>>a[i];
    v.push_back(oo);
    for(int i=1;i<=n;++i)
        v.push_back(-oo);
    for(int i=n;i>=1;--i){
        int x=lower_bound(v.begin(),v.end(),a[i],greater<int>())-v.begin();
        ans=max(ans,x);
        dp[i]=x;
        v[x]=a[i];
    }
    v.clear();
    v.push_back(-oo);
    for(int i=1;i<=n;++i)
        v.push_back(oo);
    for(int i=1;i<=n;++i){
        int x=lower_bound(v.begin(),v.end(),a[i]+k)-v.begin();
        ans=max(ans,x+dp[i]-1);
        x=lower_bound(v.begin(),v.end(),a[i])-v.begin();
        v[x]=a[i];
    }
    cout<<ans<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2424 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2424 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2424 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2552 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 1 ms 2524 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 6604 KB Output is correct
2 Correct 41 ms 6560 KB Output is correct
3 Correct 43 ms 6596 KB Output is correct
4 Correct 41 ms 6604 KB Output is correct
5 Correct 29 ms 6604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 3028 KB Output is correct
2 Correct 13 ms 3028 KB Output is correct
3 Correct 10 ms 3028 KB Output is correct
4 Correct 8 ms 3028 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 8 ms 3280 KB Output is correct
7 Correct 9 ms 3028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 3792 KB Output is correct
2 Correct 19 ms 3960 KB Output is correct
3 Correct 36 ms 6772 KB Output is correct
4 Correct 32 ms 6604 KB Output is correct
5 Correct 20 ms 3792 KB Output is correct
6 Correct 26 ms 6348 KB Output is correct
7 Correct 33 ms 6348 KB Output is correct
8 Correct 16 ms 3792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2424 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2384 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2552 KB Output is correct
23 Correct 1 ms 2384 KB Output is correct
24 Correct 2 ms 2384 KB Output is correct
25 Correct 1 ms 2524 KB Output is correct
26 Correct 1 ms 2384 KB Output is correct
27 Correct 43 ms 6604 KB Output is correct
28 Correct 41 ms 6560 KB Output is correct
29 Correct 43 ms 6596 KB Output is correct
30 Correct 41 ms 6604 KB Output is correct
31 Correct 29 ms 6604 KB Output is correct
32 Correct 11 ms 3028 KB Output is correct
33 Correct 13 ms 3028 KB Output is correct
34 Correct 10 ms 3028 KB Output is correct
35 Correct 8 ms 3028 KB Output is correct
36 Correct 1 ms 2384 KB Output is correct
37 Correct 8 ms 3280 KB Output is correct
38 Correct 9 ms 3028 KB Output is correct
39 Correct 19 ms 3792 KB Output is correct
40 Correct 19 ms 3960 KB Output is correct
41 Correct 36 ms 6772 KB Output is correct
42 Correct 32 ms 6604 KB Output is correct
43 Correct 20 ms 3792 KB Output is correct
44 Correct 26 ms 6348 KB Output is correct
45 Correct 33 ms 6348 KB Output is correct
46 Correct 16 ms 3792 KB Output is correct
47 Correct 21 ms 3792 KB Output is correct
48 Correct 20 ms 3792 KB Output is correct
49 Correct 38 ms 6604 KB Output is correct
50 Correct 27 ms 6776 KB Output is correct
51 Correct 24 ms 6092 KB Output is correct
52 Correct 36 ms 6604 KB Output is correct
53 Correct 26 ms 6616 KB Output is correct
54 Correct 28 ms 6604 KB Output is correct
55 Correct 31 ms 6480 KB Output is correct