Submission #1097094

#TimeUsernameProblemLanguageResultExecution timeMemory
1097094NiosakaruGlobal Warming (CEOI18_glo)C++17
100 / 100
44 ms4700 KiB
#include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define N 200200 int n , x , rt , p , b[N] , a[N] , lis[N]; signed main(){ cin.tie(0)->sync_with_stdio(0); cin >> n >> x , memset(b , 0x3f , sizeof b); for (int i = 1 ; i <= n ; i ++) cin >> a[i] , p = lower_bound(b + 1,b + n + 1,a[i]) - b , rt = max(rt,p) , lis[i] = p , b[p] = a[i]; memset(b , 0x3f , sizeof b); for (int i = n ; i ; i --){ p = lower_bound(b + 1,b + n + 1,-a[i]) - b; rt = max(rt , p + lis[i] - 1); p = lower_bound(b + 1,b + n + 1,-a[i]-x) - b , b[p] = -a[i]-x; } cout << rt << '\n'; 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...