제출 #1243734

#제출 시각아이디문제언어결과실행 시간메모리
1243734wedonttalkanymoreGlobal Warming (CEOI18_glo)C++20
28 / 100
2095 ms2872 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define pii pair<ll, ll> #define fi first #define se second const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320; int dp[N][2]; int n, x; int a[N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> x; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) { dp[i][0] = 1; for (int j = 1; j < i; j++) { if (a[j] < a[i]) { dp[i][0] = max(dp[i][0], dp[j][0] + 1); dp[i][1] = max(dp[i][1], dp[j][1] + 1); } } int Left = max(0LL, a[i] - x - 1); int Right = a[i] + x - 1; for (int j = 1; j < i; j++) { if (Left <= a[j] && a[j] <= Right) { dp[i][1] = max(dp[i][1], dp[j][0] + 1); } } } int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 0; j <= 1; j++) ans = max(ans, dp[i][j]); } 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...