Submission #1048964

# Submission time Handle Problem Language Result Execution time Memory
1048964 2024-08-08T11:38:59 Z matere Global Warming (CEOI18_glo) C++14
62 / 100
63 ms 10024 KB
#include<bits/stdc++.h>
using namespace std;
pair<long long,long long>step[200005];
long long a[200005],d[200005],dc[200005],ls;
int main(){
    long long n,x;
    cin>>n>>x;
    d[0]=-2e9-1;
    for(long long i=1;i<=n;i++) d[i]=2e9+1;
    for(long long i=1;i<=n;i++){
        cin>>a[i];
        long long l=0,r=n+1;
        while(l+1<r){
            long long mid=(l+r)/2;
            if(d[mid]<a[i]) l=mid;
            else r=mid;
        }
        l++;
        if(d[l]>a[i]){
            step[i]={l,d[l]};
            d[l]=a[i];
            ls=max(ls,l);
        }
    }
    d[n+1]=2e9+1;
    long long ans=ls,ld=0;
    dc[0]=2e9+1;
    for(long long i=1;i<=n;i++) dc[i]=-2e9-1;
    for(long long i=n;i>=1;i--){
        d[step[i].first]=step[i].second;
        if(d[step[i].first]==2e9+1) ls--;
        a[i]+=x;
        long long l=0,r=n+1;
        while(l+1<r){
            long long mid=(l+r)/2;
            if(dc[mid]>a[i]) l=mid;
            else r=mid;
        }
        l++;
        if(dc[l]<a[i]){
            dc[l]=a[i];
            ld=max(ld,l);
        }
        l=0,r=n+1;
        while(l+1<r){
            long long mid=(l+r)/2;
            if(dc[mid]>d[ls]) l=mid;
            else r=mid;
        }
        ans=max(ans,ls+l);
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6588 KB Output is correct
9 Correct 0 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 0 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6588 KB Output is correct
9 Correct 0 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 0 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 0 ms 6492 KB Output is correct
15 Correct 1 ms 6588 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6588 KB Output is correct
9 Correct 0 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 0 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 0 ms 6492 KB Output is correct
15 Correct 1 ms 6588 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6488 KB Output is correct
20 Incorrect 1 ms 6492 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 9152 KB Output is correct
2 Correct 61 ms 9340 KB Output is correct
3 Correct 63 ms 9552 KB Output is correct
4 Correct 62 ms 9472 KB Output is correct
5 Correct 47 ms 8940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 7260 KB Output is correct
2 Correct 15 ms 7216 KB Output is correct
3 Correct 15 ms 7260 KB Output is correct
4 Correct 13 ms 6892 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 11 ms 6960 KB Output is correct
7 Correct 14 ms 7260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 7512 KB Output is correct
2 Correct 29 ms 7732 KB Output is correct
3 Correct 61 ms 10024 KB Output is correct
4 Correct 45 ms 9156 KB Output is correct
5 Correct 22 ms 7220 KB Output is correct
6 Correct 38 ms 9240 KB Output is correct
7 Correct 51 ms 9936 KB Output is correct
8 Correct 27 ms 7508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6588 KB Output is correct
9 Correct 0 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 0 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 0 ms 6492 KB Output is correct
15 Correct 1 ms 6588 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 1 ms 6492 KB Output is correct
18 Correct 1 ms 6492 KB Output is correct
19 Correct 1 ms 6488 KB Output is correct
20 Incorrect 1 ms 6492 KB Output isn't correct
21 Halted 0 ms 0 KB -