Submission #868007

#TimeUsernameProblemLanguageResultExecution timeMemory
868007WLZGlobal Warming (CEOI18_glo)C++17
0 / 100
2067 ms14160 KiB
#include <bits/stdc++.h> using namespace std; constexpr int INF = 0x3f3f3f3f; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, x; cin >> n >> x; vector<int> t(n + 1); t[0] = -INF; for (int i = 1; i <= n; i++) cin >> t[i]; vector dp(n + 1, vector<int>(2, 0)); for (int i = 1; i <= n; i++) { for (int j = 0; j < i; j++) { if (t[j] < t[i]) { dp[i][0] = max(dp[i][0], dp[j][0] + 1); dp[i][1] = max(dp[i][1], dp[j][1] + 1); } if (t[j] < t[i] + x) dp[i][1] = max(dp[i][1], dp[j][0] + 1); } } cout << max(dp[n][0], dp[n][1]) << '\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...