Submission #129209

# Submission time Handle Problem Language Result Execution time Memory
129209 2019-07-11T20:33:13 Z mraron Global Warming (CEOI18_glo) C++14
100 / 100
187 ms 4976 KB
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,x;
    cin>>n>>x;
    vector<int> t(n);
    for(int i=0;i<n;++i) {
        cin>>t[i];
    }

    vector<int> len(n);
    vector<int> lis;
    for(int i=0;i<n;++i) {
        auto it=lower_bound(lis.begin(), lis.end(), t[i]);
        if(it==lis.end()) {
            lis.push_back(t[i]);
            len[i]=lis.size();
        }else {
            *it=t[i];
            len[i]=it-lis.begin()+1;
        }

    }

    /*for(auto i:len) {
        cerr<<i<<" ";
    }cerr<<"\n";*/
    vector<int> lds;
    int ans=lis.size();
    for(int i=n-1;i>=0;i--) {
        //for(auto j:lds) cerr<<j<<" ";cerr<<"\n";

        int pos;
        auto it2=lower_bound(lds.begin(), lds.end(), -t[i]);

        if(it2==lds.end()) pos=lds.size();
        else pos=it2-lds.begin();
        //cerr<<len[i]<<" "<<pos<<"\n";
        ans=max(ans, pos+len[i]);

        auto it=lower_bound(lds.begin(), lds.end(), -t[i]-x);

        if(it==lds.end()) {
            lds.push_back(-t[i]-x);
        }else {
            *it=-t[i]-x;
        }
    }

    cout<<ans<<"\n";


    return 0;
}
/*
8 10
7 3 5 12 2 7 3 4

3 1
1 2 2

3 0
1 2 2
*/
# 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 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 256 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 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 404 KB Output is correct
16 Correct 2 ms 504 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 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 404 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 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 3 ms 376 KB Output is correct
26 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 183 ms 2360 KB Output is correct
2 Correct 184 ms 2288 KB Output is correct
3 Correct 183 ms 2496 KB Output is correct
4 Correct 185 ms 2296 KB Output is correct
5 Correct 120 ms 3508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1272 KB Output is correct
2 Correct 47 ms 1160 KB Output is correct
3 Correct 46 ms 1164 KB Output is correct
4 Correct 31 ms 1272 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 30 ms 1400 KB Output is correct
7 Correct 44 ms 1188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 1656 KB Output is correct
2 Correct 88 ms 1784 KB Output is correct
3 Correct 187 ms 2696 KB Output is correct
4 Correct 120 ms 3696 KB Output is correct
5 Correct 62 ms 2292 KB Output is correct
6 Correct 114 ms 3540 KB Output is correct
7 Correct 155 ms 3552 KB Output is correct
8 Correct 86 ms 1756 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 256 KB Output is correct
10 Correct 2 ms 252 KB Output is correct
11 Correct 2 ms 256 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 256 KB Output is correct
15 Correct 2 ms 404 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 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 3 ms 376 KB Output is correct
26 Correct 2 ms 380 KB Output is correct
27 Correct 183 ms 2360 KB Output is correct
28 Correct 184 ms 2288 KB Output is correct
29 Correct 183 ms 2496 KB Output is correct
30 Correct 185 ms 2296 KB Output is correct
31 Correct 120 ms 3508 KB Output is correct
32 Correct 46 ms 1272 KB Output is correct
33 Correct 47 ms 1160 KB Output is correct
34 Correct 46 ms 1164 KB Output is correct
35 Correct 31 ms 1272 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 30 ms 1400 KB Output is correct
38 Correct 44 ms 1188 KB Output is correct
39 Correct 88 ms 1656 KB Output is correct
40 Correct 88 ms 1784 KB Output is correct
41 Correct 187 ms 2696 KB Output is correct
42 Correct 120 ms 3696 KB Output is correct
43 Correct 62 ms 2292 KB Output is correct
44 Correct 114 ms 3540 KB Output is correct
45 Correct 155 ms 3552 KB Output is correct
46 Correct 86 ms 1756 KB Output is correct
47 Correct 91 ms 2112 KB Output is correct
48 Correct 92 ms 2108 KB Output is correct
49 Correct 185 ms 3952 KB Output is correct
50 Correct 121 ms 4200 KB Output is correct
51 Correct 95 ms 3568 KB Output is correct
52 Correct 126 ms 4336 KB Output is correct
53 Correct 125 ms 4336 KB Output is correct
54 Correct 165 ms 4976 KB Output is correct
55 Correct 175 ms 3856 KB Output is correct