답안 #934951

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
934951 2024-02-28T09:10:23 Z tamir1 Global Warming (CEOI18_glo) C++14
100 / 100
42 ms 6420 KB
#include<bits/stdc++.h>
#define ll long long
#define all(v) (v).begin(),(v).end()
using namespace std;
ll i,j,n,x,a[200005],b[200005],ans;
vector<ll> v;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> x;
	for(i=1;i<=n;i++){
		cin >> a[i];
		j=lower_bound(all(v),a[i]+x)-v.begin();
		b[i]=j+1;
		j=lower_bound(all(v),a[i])-v.begin();
		if(j==v.size()) v.push_back(a[i]);
		else v[j]=a[i];
	}
	v.clear();
	for(i=n;i>=1;i--){
		j=lower_bound(all(v),-a[i])-v.begin();
		ans=max(ans,b[i]+j);
		if(j==v.size()) v.push_back(-a[i]);
		else v[j]=-a[i];
	}
	cout << ans;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:17:7: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   if(j==v.size()) v.push_back(a[i]);
      |      ~^~~~~~~~~~
glo.cpp:24:7: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if(j==v.size()) v.push_back(-a[i]);
      |      ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2504 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 2 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2504 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 2 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2504 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 2 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2392 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 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 41 ms 4828 KB Output is correct
2 Correct 42 ms 5108 KB Output is correct
3 Correct 41 ms 4856 KB Output is correct
4 Correct 41 ms 4668 KB Output is correct
5 Correct 24 ms 5080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 3160 KB Output is correct
2 Correct 10 ms 3164 KB Output is correct
3 Correct 10 ms 3160 KB Output is correct
4 Correct 6 ms 3296 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 6 ms 3296 KB Output is correct
7 Correct 8 ms 3420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 3420 KB Output is correct
2 Correct 19 ms 3548 KB Output is correct
3 Correct 38 ms 5456 KB Output is correct
4 Correct 24 ms 5592 KB Output is correct
5 Correct 12 ms 3836 KB Output is correct
6 Correct 22 ms 5336 KB Output is correct
7 Correct 23 ms 6100 KB Output is correct
8 Correct 16 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2504 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 2 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2648 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2392 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 1 ms 2396 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 41 ms 4828 KB Output is correct
28 Correct 42 ms 5108 KB Output is correct
29 Correct 41 ms 4856 KB Output is correct
30 Correct 41 ms 4668 KB Output is correct
31 Correct 24 ms 5080 KB Output is correct
32 Correct 10 ms 3160 KB Output is correct
33 Correct 10 ms 3164 KB Output is correct
34 Correct 10 ms 3160 KB Output is correct
35 Correct 6 ms 3296 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 6 ms 3296 KB Output is correct
38 Correct 8 ms 3420 KB Output is correct
39 Correct 18 ms 3420 KB Output is correct
40 Correct 19 ms 3548 KB Output is correct
41 Correct 38 ms 5456 KB Output is correct
42 Correct 24 ms 5592 KB Output is correct
43 Correct 12 ms 3836 KB Output is correct
44 Correct 22 ms 5336 KB Output is correct
45 Correct 23 ms 6100 KB Output is correct
46 Correct 16 ms 3676 KB Output is correct
47 Correct 20 ms 3576 KB Output is correct
48 Correct 19 ms 3676 KB Output is correct
49 Correct 40 ms 5504 KB Output is correct
50 Correct 28 ms 6140 KB Output is correct
51 Correct 20 ms 4828 KB Output is correct
52 Correct 25 ms 5580 KB Output is correct
53 Correct 23 ms 5592 KB Output is correct
54 Correct 24 ms 6420 KB Output is correct
55 Correct 33 ms 5412 KB Output is correct