Submission #917701

# Submission time Handle Problem Language Result Execution time Memory
917701 2024-01-28T15:27:07 Z PM1 Global Warming (CEOI18_glo) C++17
100 / 100
43 ms 5852 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
const int mxn=2e5+5;
ll n,a[mxn],lis[mxn],k,ans=0;
vector<int>v;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		int x=lower_bound(v.begin(),v.end(),a[i])-v.begin();
		if(x==v.size())
			v.push_back(a[i]);
		else
			v[x]=a[i];
		lis[i]=x+1;
	}
	ans=v.size();
	v.clear();
	v.push_back(2e9);
	for(int i=n;i>0;i--){
		int l=0,r=v.size();
		while(r-l>1){
			int mid=(l+r)/2;
			if(v[mid]>a[i]-k)l=mid;
			else r=mid;
		}
		ans=max(ans,l+lis[i]);
		//cout<<l<<" "<<lis[i]<<endl;
		l=0;r=v.size();
		while(r-l>1){
			int mid=(l+r)/2;
			if(v[mid]>a[i])l=mid;
			else r=mid;
		}
		if(r==v.size())
			v.push_back(a[i]);
		else 
			v[r]=a[i];
		

	}
	cout<<ans<<'\n';
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:15:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   if(x==v.size())
      |      ~^~~~~~~~~~
glo.cpp:39:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   if(r==v.size())
      |      ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2512 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2512 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2512 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2512 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2512 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2512 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2764 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 5460 KB Output is correct
2 Correct 40 ms 5496 KB Output is correct
3 Correct 41 ms 5456 KB Output is correct
4 Correct 43 ms 5472 KB Output is correct
5 Correct 42 ms 5084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 3188 KB Output is correct
2 Correct 10 ms 3160 KB Output is correct
3 Correct 10 ms 3184 KB Output is correct
4 Correct 10 ms 3164 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 9 ms 3164 KB Output is correct
7 Correct 9 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 3748 KB Output is correct
2 Correct 22 ms 3720 KB Output is correct
3 Correct 40 ms 5456 KB Output is correct
4 Correct 41 ms 5080 KB Output is correct
5 Correct 20 ms 3552 KB Output is correct
6 Correct 27 ms 5216 KB Output is correct
7 Correct 41 ms 5744 KB Output is correct
8 Correct 19 ms 3672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2512 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2512 KB Output is correct
9 Correct 1 ms 2648 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2764 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 40 ms 5460 KB Output is correct
28 Correct 40 ms 5496 KB Output is correct
29 Correct 41 ms 5456 KB Output is correct
30 Correct 43 ms 5472 KB Output is correct
31 Correct 42 ms 5084 KB Output is correct
32 Correct 10 ms 3188 KB Output is correct
33 Correct 10 ms 3160 KB Output is correct
34 Correct 10 ms 3184 KB Output is correct
35 Correct 10 ms 3164 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 9 ms 3164 KB Output is correct
38 Correct 9 ms 3164 KB Output is correct
39 Correct 19 ms 3748 KB Output is correct
40 Correct 22 ms 3720 KB Output is correct
41 Correct 40 ms 5456 KB Output is correct
42 Correct 41 ms 5080 KB Output is correct
43 Correct 20 ms 3552 KB Output is correct
44 Correct 27 ms 5216 KB Output is correct
45 Correct 41 ms 5744 KB Output is correct
46 Correct 19 ms 3672 KB Output is correct
47 Correct 20 ms 3672 KB Output is correct
48 Correct 20 ms 3660 KB Output is correct
49 Correct 40 ms 5468 KB Output is correct
50 Correct 42 ms 5084 KB Output is correct
51 Correct 33 ms 4464 KB Output is correct
52 Correct 43 ms 5336 KB Output is correct
53 Correct 29 ms 5220 KB Output is correct
54 Correct 43 ms 5852 KB Output is correct
55 Correct 35 ms 5456 KB Output is correct