Submission #169988

# Submission time Handle Problem Language Result Execution time Memory
169988 2019-12-23T14:06:50 Z mhy908 Global Warming (CEOI18_glo) C++14
17 / 100
76 ms 5492 KB
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL llinf=9000000000000000000;
const int inf=2000000000;
int n;
LL x, arr[200010];
vector<LL> lis, lds;
int dplis[200010], dplds[200010], ans;
int main()
{
    scanf("%d %lld", &n, &x);
    for(int i=1; i<=n; i++)scanf("%lld", &arr[i]);
    for(int i=1; i<=n; i++){
        auto it=lower_bound(lis.begin(), lis.end(), arr[i]);
        if(it==lis.end())lis.pb(arr[i]);
        else *it=arr[i];
        dplis[i]=lower_bound(lis.begin(), lis.end(), arr[i+1]+x)-lis.begin();
    }
    ans=dplis[n];
    for(int i=n; i>=1; i--){
        auto it=lower_bound(lds.begin(), lds.end(), -arr[i]);
        if(it==lds.end())lds.pb(-arr[i]);
        else *it=-arr[i];
        dplds[i]=lds.size();
    }
    ans=dplds[1];
    for(int i=1; i<n; i++){
        ans=max(ans, dplis[i]+dplds[i+1]);
    }
    printf("%d", ans);
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %lld", &n, &x);
     ~~~~~^~~~~~~~~~~~~~~~~~~
glo.cpp:19:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1; i<=n; i++)scanf("%lld", &arr[i]);
                            ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 3448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1912 KB Output is correct
2 Correct 35 ms 1888 KB Output is correct
3 Correct 69 ms 3420 KB Output is correct
4 Correct 52 ms 5492 KB Output is correct
5 Correct 25 ms 2928 KB Output is correct
6 Correct 43 ms 5420 KB Output is correct
7 Correct 43 ms 5100 KB Output is correct
8 Correct 29 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -