Submission #964315

#TimeUsernameProblemLanguageResultExecution timeMemory
964315AndreyGlobal Warming (CEOI18_glo)C++14
10 / 100
57 ms3936 KiB
#include <bits/stdc++.h> using namespace std; int dude(vector<int>& haha, int x) { int l = 0,r = haha.size(); while(l < r) { int m = (l+r+1)/2; if(haha[m] < x) { l = m; } else { r = m-1; } } return l; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n,x,a,ans = 0; cin >> n >> x; vector<int> haha(n+1,INT_MAX); vector<int> bruh(n+1,INT_MAX); haha[0] = 0; bruh[0] = 0; for(int i = 1; i <= n; i++) { cin >> a; int c = dude(haha,a); ans = max(ans,c+1); haha[c+1] = a; c = dude(bruh,a); ans = max(ans,c+1); bruh[c+1] = a; c = dude(haha,a+x); ans = max(ans,c+1); bruh[c+1] = a; } 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...