Submission #78516

# Submission time Handle Problem Language Result Execution time Memory
78516 2018-10-05T14:48:09 Z igzi Global Warming (CEOI18_glo) C++17
100 / 100
164 ms 23228 KB
#include <bits/stdc++.h>
#define maxN 200005

using namespace std;

int a[maxN],d[maxN],n,x,i;

void LDS(){
vector <int> v;
for(int i=0;i<n;i++) v.push_back(0);
for(int i=n-1;i>=0;i--){
    int tmp=upper_bound(v.begin(),v.end(),a[i])-v.begin()-1;
    v[tmp]=a[i];
    d[i]=n-tmp;
    //cout<<i<<" "<<d[i]<<endl;
}
}
int LIS(){
vector <int> v;
int ans=0;
for(int i=0;i<n;i++){
    int tmp=lower_bound(v.begin(),v.end(),a[i])-v.begin();
    int p;
    p=lower_bound(v.begin(),v.end(),a[i]+x)-v.begin();
    //cout<<p<<" "<<d[i]<<endl;
    ans=max(ans,p+d[i]);
    if(tmp==v.size()) v.push_back(a[i]);
    else v[tmp]=a[i];
}
return ans;
}

int main() {
    cin>>n>>x;
    for(i=0;i<n;i++) cin>>a[i];
    LDS();
    cout<<LIS()<<endl;
    return 0;
}

Compilation message

glo.cpp: In function 'int LIS()':
glo.cpp:27:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(tmp==v.size()) v.push_back(a[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 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 2 ms 428 KB Output is correct
9 Correct 2 ms 444 KB Output is correct
10 Correct 2 ms 448 KB Output is correct
11 Correct 2 ms 452 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 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 2 ms 428 KB Output is correct
9 Correct 2 ms 444 KB Output is correct
10 Correct 2 ms 448 KB Output is correct
11 Correct 2 ms 452 KB Output is correct
12 Correct 2 ms 456 KB Output is correct
13 Correct 2 ms 516 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 2 ms 656 KB Output is correct
17 Correct 2 ms 656 KB Output is correct
18 Correct 2 ms 656 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 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 2 ms 428 KB Output is correct
9 Correct 2 ms 444 KB Output is correct
10 Correct 2 ms 448 KB Output is correct
11 Correct 2 ms 452 KB Output is correct
12 Correct 2 ms 456 KB Output is correct
13 Correct 2 ms 516 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 2 ms 656 KB Output is correct
17 Correct 2 ms 656 KB Output is correct
18 Correct 2 ms 656 KB Output is correct
19 Correct 2 ms 656 KB Output is correct
20 Correct 3 ms 656 KB Output is correct
21 Correct 3 ms 776 KB Output is correct
22 Correct 3 ms 808 KB Output is correct
23 Correct 2 ms 808 KB Output is correct
24 Correct 2 ms 808 KB Output is correct
25 Correct 3 ms 808 KB Output is correct
26 Correct 3 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 164 ms 5148 KB Output is correct
2 Correct 142 ms 7032 KB Output is correct
3 Correct 143 ms 8948 KB Output is correct
4 Correct 149 ms 10828 KB Output is correct
5 Correct 99 ms 12048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 12048 KB Output is correct
2 Correct 35 ms 12048 KB Output is correct
3 Correct 37 ms 12048 KB Output is correct
4 Correct 30 ms 12048 KB Output is correct
5 Correct 3 ms 12048 KB Output is correct
6 Correct 45 ms 12256 KB Output is correct
7 Correct 34 ms 12796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 14464 KB Output is correct
2 Correct 87 ms 15264 KB Output is correct
3 Correct 132 ms 16480 KB Output is correct
4 Correct 97 ms 16540 KB Output is correct
5 Correct 50 ms 16540 KB Output is correct
6 Correct 119 ms 16540 KB Output is correct
7 Correct 131 ms 16540 KB Output is correct
8 Correct 63 ms 16540 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 Correct 2 ms 416 KB Output is correct
4 Correct 2 ms 416 KB Output is correct
5 Correct 2 ms 428 KB Output is correct
6 Correct 2 ms 428 KB Output is correct
7 Correct 2 ms 428 KB Output is correct
8 Correct 2 ms 428 KB Output is correct
9 Correct 2 ms 444 KB Output is correct
10 Correct 2 ms 448 KB Output is correct
11 Correct 2 ms 452 KB Output is correct
12 Correct 2 ms 456 KB Output is correct
13 Correct 2 ms 516 KB Output is correct
14 Correct 2 ms 636 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 2 ms 656 KB Output is correct
17 Correct 2 ms 656 KB Output is correct
18 Correct 2 ms 656 KB Output is correct
19 Correct 2 ms 656 KB Output is correct
20 Correct 3 ms 656 KB Output is correct
21 Correct 3 ms 776 KB Output is correct
22 Correct 3 ms 808 KB Output is correct
23 Correct 2 ms 808 KB Output is correct
24 Correct 2 ms 808 KB Output is correct
25 Correct 3 ms 808 KB Output is correct
26 Correct 3 ms 808 KB Output is correct
27 Correct 164 ms 5148 KB Output is correct
28 Correct 142 ms 7032 KB Output is correct
29 Correct 143 ms 8948 KB Output is correct
30 Correct 149 ms 10828 KB Output is correct
31 Correct 99 ms 12048 KB Output is correct
32 Correct 41 ms 12048 KB Output is correct
33 Correct 35 ms 12048 KB Output is correct
34 Correct 37 ms 12048 KB Output is correct
35 Correct 30 ms 12048 KB Output is correct
36 Correct 3 ms 12048 KB Output is correct
37 Correct 45 ms 12256 KB Output is correct
38 Correct 34 ms 12796 KB Output is correct
39 Correct 69 ms 14464 KB Output is correct
40 Correct 87 ms 15264 KB Output is correct
41 Correct 132 ms 16480 KB Output is correct
42 Correct 97 ms 16540 KB Output is correct
43 Correct 50 ms 16540 KB Output is correct
44 Correct 119 ms 16540 KB Output is correct
45 Correct 131 ms 16540 KB Output is correct
46 Correct 63 ms 16540 KB Output is correct
47 Correct 77 ms 16540 KB Output is correct
48 Correct 70 ms 16540 KB Output is correct
49 Correct 141 ms 16540 KB Output is correct
50 Correct 107 ms 16540 KB Output is correct
51 Correct 77 ms 16540 KB Output is correct
52 Correct 105 ms 18120 KB Output is correct
53 Correct 123 ms 19372 KB Output is correct
54 Correct 124 ms 21276 KB Output is correct
55 Correct 137 ms 23228 KB Output is correct