제출 #910583

#제출 시각아이디문제언어결과실행 시간메모리
910583panGlobal Warming (CEOI18_glo)C++17
100 / 100
89 ms6604 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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]);
      |       ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...