제출 #1149819

#제출 시각아이디문제언어결과실행 시간메모리
1149819zhasynGlobal Warming (CEOI18_glo)C++20
25 / 100
2095 ms3400 KiB
#include <bits/stdc++.h>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 2 * 1e5 + 100, M = 4096 + 10, len = 21, inf = 1e18;
const ll mod = 1e9 + 7;
ll um(ll a, ll b){
	return (1LL * a * b % mod + mod) % mod;
}
ll n, dp[N], a[N];
ll got(){
	for(ll i = 1; i <= n; i++){
		dp[i] = LLONG_MAX;
	}
	dp[0] = LLONG_MIN;
	ll mx = 1;
	for(ll i = 1; i <= n; i++){
		ll k = lower_bound(dp, dp + n, a[i]) - dp;
		if(a[i] > dp[k - 1]){
			dp[k] = a[i];
			mx = max(mx, k);
		}
	}
	return mx;
}

int main(){
  	ios::sync_with_stdio(false);
  	cin.tie(NULL);
  	ll x, ans = 1;
  	cin >> n >> x;
  	for(ll i = 1; i <= n; i++){
  		cin >> a[i];
  	}
  	if(x == 0){
  		cout << got();
  		return 0;
  	}
	for(ll k = -x; k <= 0; k++){
		for(ll i = 1; i <= n; i++){
			a[i] += k;
			ans = max(ans, got());
		}
		for(ll i = 1; i <= n; i++){
			a[i] -= k;
		}
	}
	cout << ans;
  return 0;
}

 
#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...