# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
943812 |
2024-03-12T01:22:48 Z |
pcc |
Global Warming (CEOI18_glo) |
C++17 |
|
50 ms |
4308 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 2e5+10;
int N,X;
int arr[mxn];
int dp[mxn];
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>X;
for(int i = 1;i<=N;i++)cin>>arr[i];
vector<int> v;
for(int i = N;i>=1;i--){
auto pos = lower_bound(v.begin(),v.end(),-arr[i])-v.begin();
dp[i] = pos+1;
if(pos == v.size())v.push_back(-arr[i]);
else v[pos] = -arr[i];
}
v.clear();
int ans = *max_element(dp+1,dp+N+1);
for(int i = 1;i+1<=N;i++){
auto pos = lower_bound(v.begin(),v.end(),arr[i])-v.begin();
if(pos == v.size())v.push_back(arr[i]);
else v[pos] = arr[i];
int tans = dp[i+1];
tans += lower_bound(v.begin(),v.end(),arr[i+1]+X)-v.begin();
ans = max(ans,tans);
}
cout<<ans<<'\n';
}
Compilation message
glo.cpp: In function 'int main()':
glo.cpp:25:10: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
25 | if(pos == v.size())v.push_back(-arr[i]);
| ~~~~^~~~~~~~~~~
glo.cpp:32:10: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if(pos == v.size())v.push_back(arr[i]);
| ~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 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 |
344 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 |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 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 |
344 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 |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 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 |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
3928 KB |
Output is correct |
2 |
Correct |
50 ms |
3920 KB |
Output is correct |
3 |
Correct |
46 ms |
3732 KB |
Output is correct |
4 |
Correct |
43 ms |
3932 KB |
Output is correct |
5 |
Correct |
20 ms |
3540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1116 KB |
Output is correct |
2 |
Correct |
10 ms |
1352 KB |
Output is correct |
3 |
Correct |
12 ms |
1116 KB |
Output is correct |
4 |
Correct |
6 ms |
1372 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
5 ms |
1116 KB |
Output is correct |
7 |
Correct |
10 ms |
1136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
2136 KB |
Output is correct |
2 |
Correct |
18 ms |
2140 KB |
Output is correct |
3 |
Correct |
37 ms |
3728 KB |
Output is correct |
4 |
Correct |
21 ms |
3544 KB |
Output is correct |
5 |
Correct |
10 ms |
2016 KB |
Output is correct |
6 |
Correct |
19 ms |
3552 KB |
Output is correct |
7 |
Correct |
21 ms |
4200 KB |
Output is correct |
8 |
Correct |
15 ms |
2140 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 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 |
348 KB |
Output is correct |
25 |
Correct |
0 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
49 ms |
3928 KB |
Output is correct |
28 |
Correct |
50 ms |
3920 KB |
Output is correct |
29 |
Correct |
46 ms |
3732 KB |
Output is correct |
30 |
Correct |
43 ms |
3932 KB |
Output is correct |
31 |
Correct |
20 ms |
3540 KB |
Output is correct |
32 |
Correct |
10 ms |
1116 KB |
Output is correct |
33 |
Correct |
10 ms |
1352 KB |
Output is correct |
34 |
Correct |
12 ms |
1116 KB |
Output is correct |
35 |
Correct |
6 ms |
1372 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
5 ms |
1116 KB |
Output is correct |
38 |
Correct |
10 ms |
1136 KB |
Output is correct |
39 |
Correct |
18 ms |
2136 KB |
Output is correct |
40 |
Correct |
18 ms |
2140 KB |
Output is correct |
41 |
Correct |
37 ms |
3728 KB |
Output is correct |
42 |
Correct |
21 ms |
3544 KB |
Output is correct |
43 |
Correct |
10 ms |
2016 KB |
Output is correct |
44 |
Correct |
19 ms |
3552 KB |
Output is correct |
45 |
Correct |
21 ms |
4200 KB |
Output is correct |
46 |
Correct |
15 ms |
2140 KB |
Output is correct |
47 |
Correct |
21 ms |
2136 KB |
Output is correct |
48 |
Correct |
21 ms |
2140 KB |
Output is correct |
49 |
Correct |
44 ms |
3920 KB |
Output is correct |
50 |
Correct |
21 ms |
3552 KB |
Output is correct |
51 |
Correct |
19 ms |
3036 KB |
Output is correct |
52 |
Correct |
23 ms |
3720 KB |
Output is correct |
53 |
Correct |
19 ms |
3808 KB |
Output is correct |
54 |
Correct |
22 ms |
4308 KB |
Output is correct |
55 |
Correct |
34 ms |
3984 KB |
Output is correct |