Submission #1103955

# Submission time Handle Problem Language Result Execution time Memory
1103955 2024-10-22T12:52:23 Z vjudge1 Global Warming (CEOI18_glo) C++17
100 / 100
41 ms 4308 KB
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int arr[200005];
int len[200005];
int mx,idx;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n,x; cin >> n >> x;
	for(int i=0;i<n;++i) cin >> arr[i];
	vector<int> dp;
	for(int i=0;i<n;++i){
		idx=lower_bound(dp.begin(),dp.end(),arr[i])-dp.begin();
        if(idx==dp.size()) dp.push_back(arr[i]);
        else dp[idx]=arr[i];
		len[i] = idx+1;
		mx=max(mx,len[i]);
	}
    dp.clear();
    for(int i=n-1;i>0;--i){
        idx=lower_bound(dp.begin(),dp.end(),-arr[i]+x)-dp.begin();
        mx=max(mx,len[i]+idx);
        idx=lower_bound(dp.begin(),dp.end(),-arr[i])-dp.begin();
        if(idx==dp.size()) dp.push_back(-arr[i]);
        else dp[idx]=-arr[i];

    }
	cout << mx << endl;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         if(idx==dp.size()) dp.push_back(arr[i]);
      |            ~~~^~~~~~~~~~~
glo.cpp:25:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(idx==dp.size()) dp.push_back(-arr[i]);
      |            ~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 552 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 552 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 552 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1864 KB Output is correct
2 Correct 38 ms 3112 KB Output is correct
3 Correct 38 ms 3832 KB Output is correct
4 Correct 36 ms 1872 KB Output is correct
5 Correct 20 ms 3540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1104 KB Output is correct
2 Correct 10 ms 1104 KB Output is correct
3 Correct 9 ms 1352 KB Output is correct
4 Correct 6 ms 1360 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 5 ms 1360 KB Output is correct
7 Correct 8 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1104 KB Output is correct
2 Correct 20 ms 2128 KB Output is correct
3 Correct 40 ms 3912 KB Output is correct
4 Correct 23 ms 3540 KB Output is correct
5 Correct 12 ms 2004 KB Output is correct
6 Correct 26 ms 3540 KB Output is correct
7 Correct 24 ms 4308 KB Output is correct
8 Correct 15 ms 1104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 552 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 36 ms 1864 KB Output is correct
28 Correct 38 ms 3112 KB Output is correct
29 Correct 38 ms 3832 KB Output is correct
30 Correct 36 ms 1872 KB Output is correct
31 Correct 20 ms 3540 KB Output is correct
32 Correct 10 ms 1104 KB Output is correct
33 Correct 10 ms 1104 KB Output is correct
34 Correct 9 ms 1352 KB Output is correct
35 Correct 6 ms 1360 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 5 ms 1360 KB Output is correct
38 Correct 8 ms 1360 KB Output is correct
39 Correct 23 ms 1104 KB Output is correct
40 Correct 20 ms 2128 KB Output is correct
41 Correct 40 ms 3912 KB Output is correct
42 Correct 23 ms 3540 KB Output is correct
43 Correct 12 ms 2004 KB Output is correct
44 Correct 26 ms 3540 KB Output is correct
45 Correct 24 ms 4308 KB Output is correct
46 Correct 15 ms 1104 KB Output is correct
47 Correct 23 ms 2128 KB Output is correct
48 Correct 24 ms 2128 KB Output is correct
49 Correct 41 ms 3920 KB Output is correct
50 Correct 22 ms 3708 KB Output is correct
51 Correct 20 ms 3040 KB Output is correct
52 Correct 24 ms 3792 KB Output is correct
53 Correct 20 ms 3792 KB Output is correct
54 Correct 23 ms 2516 KB Output is correct
55 Correct 34 ms 3920 KB Output is correct