Submission #169992

# Submission time Handle Problem Language Result Execution time Memory
169992 2019-12-23T14:14:11 Z mhy908 Global Warming (CEOI18_glo) C++14
62 / 100
78 ms 7144 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;
LL minlds[200010];
int main()
{
    scanf("%d %lld", &n, &x);
    for(int i=1; i<=n; i++)scanf("%lld", &arr[i]);
    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=min(-arr[i], *it);
        dplds[i]=lds.size();
        minlds[i]=-lds[dplds[i]-1];
    }
    minlds[n+1]=llinf;
    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=min(arr[i], *it);
        dplis[i]=lower_bound(lis.begin(), lis.end(), minlds[i+1]+x)-lis.begin();
    }
    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:19: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:20: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 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Incorrect 2 ms 376 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 72 ms 5020 KB Output is correct
2 Correct 71 ms 5016 KB Output is correct
3 Correct 78 ms 5008 KB Output is correct
4 Correct 73 ms 4984 KB Output is correct
5 Correct 51 ms 7020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 1500 KB Output is correct
2 Correct 19 ms 1532 KB Output is correct
3 Correct 18 ms 1528 KB Output is correct
4 Correct 13 ms 2036 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 16 ms 2036 KB Output is correct
7 Correct 16 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2664 KB Output is correct
2 Correct 35 ms 2648 KB Output is correct
3 Correct 70 ms 5076 KB Output is correct
4 Correct 50 ms 7144 KB Output is correct
5 Correct 26 ms 3824 KB Output is correct
6 Correct 58 ms 6636 KB Output is correct
7 Correct 45 ms 7016 KB Output is correct
8 Correct 30 ms 2728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Incorrect 2 ms 376 KB Output isn't correct
20 Halted 0 ms 0 KB -