답안 #910583

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
910583 2024-01-18T06:01:33 Z pan Global Warming (CEOI18_glo) C++17
100 / 100
89 ms 6604 KB
#include <bits/stdc++.h>
//#include "bits_stdc++.h"
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;


int main()
{
	ll n,x;
	cin >> n >> x;
	ll arr[n], right[n];
	vector<ll> lis;
	for (ll i=0; i<n; ++i) cin >> arr[i];
	for (ll i=n-1; i>=0; --i) 
	{
		ll ind = lb(lis.begin(), lis.end(), -arr[i])-lis.begin();
		if (ind>=lis.size()) 
		{
			lis.pb(-arr[i]);
		}
		else
		{
			lis[ind] = -arr[i];
		}
		right[i] = ind;
	}
	ll ans = 0;
	lis.resize(0);
	for (ll i=0; i<n; ++i)
	{
		ll left = lb(lis.begin(), lis.end(), arr[i]+x) -lis.begin();
		ans = max(ans, left + right[i] + 1);
		ll ind = lb(lis.begin(), lis.end(), arr[i]) -lis.begin();
		if (ind>=lis.size()) lis.pb(arr[i]);
		else lis[ind] = arr[i];
		
	}
	cout << ans << endl;
	return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:31:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   if (ind>=lis.size())
      |       ~~~^~~~~~~~~~~~
glo.cpp:48:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   if (ind>=lis.size()) lis.pb(arr[i]);
      |       ~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 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 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 688 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 84 ms 5448 KB Output is correct
2 Correct 88 ms 5480 KB Output is correct
3 Correct 84 ms 5456 KB Output is correct
4 Correct 89 ms 5448 KB Output is correct
5 Correct 50 ms 5848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1740 KB Output is correct
2 Correct 20 ms 1628 KB Output is correct
3 Correct 23 ms 1624 KB Output is correct
4 Correct 13 ms 1880 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 12 ms 1840 KB Output is correct
7 Correct 19 ms 1628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 2904 KB Output is correct
2 Correct 46 ms 3000 KB Output is correct
3 Correct 77 ms 5456 KB Output is correct
4 Correct 50 ms 5700 KB Output is correct
5 Correct 26 ms 3028 KB Output is correct
6 Correct 49 ms 5580 KB Output is correct
7 Correct 59 ms 6220 KB Output is correct
8 Correct 40 ms 2864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 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 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 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 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 688 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 84 ms 5448 KB Output is correct
28 Correct 88 ms 5480 KB Output is correct
29 Correct 84 ms 5456 KB Output is correct
30 Correct 89 ms 5448 KB Output is correct
31 Correct 50 ms 5848 KB Output is correct
32 Correct 28 ms 1740 KB Output is correct
33 Correct 20 ms 1628 KB Output is correct
34 Correct 23 ms 1624 KB Output is correct
35 Correct 13 ms 1880 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 12 ms 1840 KB Output is correct
38 Correct 19 ms 1628 KB Output is correct
39 Correct 42 ms 2904 KB Output is correct
40 Correct 46 ms 3000 KB Output is correct
41 Correct 77 ms 5456 KB Output is correct
42 Correct 50 ms 5700 KB Output is correct
43 Correct 26 ms 3028 KB Output is correct
44 Correct 49 ms 5580 KB Output is correct
45 Correct 59 ms 6220 KB Output is correct
46 Correct 40 ms 2864 KB Output is correct
47 Correct 42 ms 2736 KB Output is correct
48 Correct 42 ms 3156 KB Output is correct
49 Correct 87 ms 5456 KB Output is correct
50 Correct 59 ms 5708 KB Output is correct
51 Correct 40 ms 4556 KB Output is correct
52 Correct 52 ms 5832 KB Output is correct
53 Correct 50 ms 5948 KB Output is correct
54 Correct 63 ms 6604 KB Output is correct
55 Correct 75 ms 5460 KB Output is correct