Submission #1085691

# Submission time Handle Problem Language Result Execution time Memory
1085691 2024-09-08T15:08:21 Z vjudge1 Global Warming (CEOI18_glo) C++17
100 / 100
39 ms 5096 KB
#include <bits/stdc++.h>
 
using namespace std;

int n, x;
int t[200005];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x;
    for (int i=0;i<n;i++)
        cin >> t[i];
    vector<int> rez;
    int lis[n], najdolga;
    for (int i=0;i<n;i++) {
        auto it=lower_bound(rez.begin(), rez.end(), t[i]);
        int index=it-rez.begin();
        lis[i]=index+1;
        if (it==rez.end())
            rez.push_back(t[i]);
        else *it=t[i];
    }
    najdolga=rez.size();
    rez.clear();
    int lds[n];
    for (int i=n-1;i>=0;i--) {
        auto it=lower_bound(rez.begin(), rez.end(), -t[i]+x);
        int index=it-rez.begin();
        lds[i]=index+1;
        it=lower_bound(rez.begin(), rez.end(), -t[i]);
        if (it==rez.end())
            rez.push_back(-t[i]);
        else *it=-t[i];
    }
    for (int i=0;i<n;i++)
        najdolga=max(najdolga, lis[i]+lds[i]-1);
    cout << najdolga;
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 856 KB Output is correct
7 Correct 0 ms 472 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 856 KB Output is correct
7 Correct 0 ms 472 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 856 KB Output is correct
7 Correct 0 ms 472 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 37 ms 4688 KB Output is correct
2 Correct 39 ms 4700 KB Output is correct
3 Correct 36 ms 4692 KB Output is correct
4 Correct 37 ms 4692 KB Output is correct
5 Correct 21 ms 4320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1368 KB Output is correct
2 Correct 9 ms 1372 KB Output is correct
3 Correct 9 ms 1372 KB Output is correct
4 Correct 5 ms 1372 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 5 ms 1372 KB Output is correct
7 Correct 8 ms 1352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2396 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 33 ms 4628 KB Output is correct
4 Correct 24 ms 4244 KB Output is correct
5 Correct 10 ms 2528 KB Output is correct
6 Correct 19 ms 4316 KB Output is correct
7 Correct 29 ms 4828 KB Output is correct
8 Correct 14 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 856 KB Output is correct
7 Correct 0 ms 472 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 604 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 37 ms 4688 KB Output is correct
28 Correct 39 ms 4700 KB Output is correct
29 Correct 36 ms 4692 KB Output is correct
30 Correct 37 ms 4692 KB Output is correct
31 Correct 21 ms 4320 KB Output is correct
32 Correct 9 ms 1368 KB Output is correct
33 Correct 9 ms 1372 KB Output is correct
34 Correct 9 ms 1372 KB Output is correct
35 Correct 5 ms 1372 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 5 ms 1372 KB Output is correct
38 Correct 8 ms 1352 KB Output is correct
39 Correct 16 ms 2396 KB Output is correct
40 Correct 16 ms 2396 KB Output is correct
41 Correct 33 ms 4628 KB Output is correct
42 Correct 24 ms 4244 KB Output is correct
43 Correct 10 ms 2528 KB Output is correct
44 Correct 19 ms 4316 KB Output is correct
45 Correct 29 ms 4828 KB Output is correct
46 Correct 14 ms 2396 KB Output is correct
47 Correct 19 ms 2392 KB Output is correct
48 Correct 22 ms 2396 KB Output is correct
49 Correct 38 ms 4708 KB Output is correct
50 Correct 19 ms 4488 KB Output is correct
51 Correct 17 ms 3388 KB Output is correct
52 Correct 21 ms 4448 KB Output is correct
53 Correct 18 ms 4572 KB Output is correct
54 Correct 26 ms 5096 KB Output is correct
55 Correct 33 ms 4700 KB Output is correct