Submission #432923

#TimeUsernameProblemLanguageResultExecution timeMemory
432923lukadupliGlobal Warming (CEOI18_glo)C++14
28 / 100
2091 ms1188 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 2e5 + 5; int n, x, arr[MAX]; int memo[MAX][2]; int rek(int pos, bool drop){ if(pos == 0) return 1; if(memo[pos][drop] > 0) return memo[pos][drop]; int maxi = 0; for(int i = 0; i < pos; i++){ if(arr[pos] > arr[i]) maxi = max(maxi, rek(i, drop)); if(arr[i] - arr[pos] < x && drop) maxi = max(maxi, rek(i, 0)); } return memo[pos][drop] = maxi + 1; } int main() { cin >> n >> x; for(int i = 0; i < n; i++) cin >> arr[i]; int maxi = 0; for(int i = 0; i < n; i++) maxi = max(maxi, rek(i, 1)); cout << maxi; /*for(int i = 0; i < n; i++){ printf("%d\n drop left: %d\n no drop left: %d\n", i, rek(i, 1), rek(i, 0)); }*/ 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...