Submission #129014

# Submission time Handle Problem Language Result Execution time Memory
129014 2019-07-11T12:30:36 Z arnold518 Global Warming (CEOI18_glo) C++14
100 / 100
85 ms 5752 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;
const int INF = numeric_limits<int>::max();

int N, X, A[MAXN+10];
int lis[MAXN+10], lds[MAXN+10], ans;
pii change[MAXN+10];

int main()
{
    int i, j;

    scanf("%d%d", &N, &X);
    for(i=1; i<=N; i++) scanf("%d", &A[i]);

    for(i=1; i<=N; i++) lis[i]=INF;
    for(i=1; i<=N; i++)
    {
        int it=lower_bound(lis+1, lis+N+1, A[i])-lis;
        change[i]={it, lis[it]};
        lis[it]=A[i];
        ans=max(ans, it);
    }

    for(i=N; i>=1; i--)
    {
        int it=lower_bound(lds+1, lds+N+1, A[i]+X, greater<int>())-lds;
        lds[it]=A[i]+X;
        lis[change[i].first]=change[i].second;
        int jt=lower_bound(lis+1, lis+N+1, A[i]+X)-lis-1;
        ans=max(ans, it+jt);
    }
    printf("%d", ans);
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:17:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
glo.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &X);
     ~~~~~^~~~~~~~~~~~~~~~
glo.cpp:20:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1; i<=N; i++) scanf("%d", &A[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 380 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 248 KB Output is correct
11 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 380 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 248 KB Output is correct
11 Correct 2 ms 376 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 376 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 380 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 248 KB Output is correct
11 Correct 2 ms 376 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 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 5416 KB Output is correct
2 Correct 83 ms 5484 KB Output is correct
3 Correct 84 ms 5368 KB Output is correct
4 Correct 85 ms 5428 KB Output is correct
5 Correct 65 ms 4980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 1528 KB Output is correct
2 Correct 21 ms 1656 KB Output is correct
3 Correct 21 ms 1628 KB Output is correct
4 Correct 17 ms 1500 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 18 ms 1528 KB Output is correct
7 Correct 18 ms 1628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 2880 KB Output is correct
2 Correct 37 ms 2936 KB Output is correct
3 Correct 75 ms 5380 KB Output is correct
4 Correct 62 ms 4984 KB Output is correct
5 Correct 31 ms 2680 KB Output is correct
6 Correct 52 ms 4900 KB Output is correct
7 Correct 54 ms 5496 KB Output is correct
8 Correct 31 ms 2808 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 380 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 248 KB Output is correct
11 Correct 2 ms 376 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 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 82 ms 5416 KB Output is correct
28 Correct 83 ms 5484 KB Output is correct
29 Correct 84 ms 5368 KB Output is correct
30 Correct 85 ms 5428 KB Output is correct
31 Correct 65 ms 4980 KB Output is correct
32 Correct 21 ms 1528 KB Output is correct
33 Correct 21 ms 1656 KB Output is correct
34 Correct 21 ms 1628 KB Output is correct
35 Correct 17 ms 1500 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 18 ms 1528 KB Output is correct
38 Correct 18 ms 1628 KB Output is correct
39 Correct 37 ms 2880 KB Output is correct
40 Correct 37 ms 2936 KB Output is correct
41 Correct 75 ms 5380 KB Output is correct
42 Correct 62 ms 4984 KB Output is correct
43 Correct 31 ms 2680 KB Output is correct
44 Correct 52 ms 4900 KB Output is correct
45 Correct 54 ms 5496 KB Output is correct
46 Correct 31 ms 2808 KB Output is correct
47 Correct 41 ms 2908 KB Output is correct
48 Correct 41 ms 2796 KB Output is correct
49 Correct 83 ms 5340 KB Output is correct
50 Correct 61 ms 4984 KB Output is correct
51 Correct 48 ms 3960 KB Output is correct
52 Correct 63 ms 5112 KB Output is correct
53 Correct 54 ms 5112 KB Output is correct
54 Correct 57 ms 5752 KB Output is correct
55 Correct 67 ms 5496 KB Output is correct