Submission #884532

#TimeUsernameProblemLanguageResultExecution timeMemory
884532ByeWorldGlobal Warming (CEOI18_glo)C++14
15 / 100
2064 ms2648 KiB
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,unroll-loops") #define bupol __builtin_popcount #define int long long #define ll long long #define ld long double #define fi first #define se second #define pb push_back #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) using namespace std; const int MAXN = 3e5+20; const int LOG = 60; const int MOD = 998244353; const int SQRT = 520; const int INF = 1e18; typedef pair<int,int> pii; typedef pair<pii,int> ipii; int n, x; int a[MAXN], pr[MAXN], su[MAXN]; vector <int> vec; int ans; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> x; for(int i=1; i<=n; i++) cin >> a[i]; for(int j=1; j<=n-1; j++){ vec.clear(); for(int i=1; i<=j; i++){ auto it = lower_bound(vec.begin(), vec.end(), a[i]); if(it == vec.end()){ vec.pb(a[i]); } else { int id = it - vec.begin(); vec[id] = a[i]; } } int en = vec.back(); for(int i=j+1; i<=n; i++){ if(en >= a[i]+x) continue; //gk legal auto it = lower_bound(vec.begin(), vec.end(), a[i]+x); if(it == vec.end()){ vec.pb(a[i]+x); } else { int id = it - vec.begin(); vec[id] = a[i]+x; } } ans = max(ans, (int)vec.size()); } cout << ans << '\n'; }
#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...