Submission #800039

#TimeUsernameProblemLanguageResultExecution timeMemory
800039NothingXDFinancial Report (JOI21_financial)C++17
28 / 100
19 ms980 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; void debug_out(){cerr<<endl;} template<typename Head, typename... Tail> void debug_out(Head H, Tail... T){ cerr << H << ' '; debug_out(T...); } #define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__) #define F first #define S second #define all(x) x.begin(), x.end() #define MP(x, y) make_pair(x, y) const int maxn = 400 + 10; const int inf = 1e9; int n, d, a[maxn], dp[maxn][maxn]; int main(){ cin >> n >> d; for (int i = 1; i <= n; i++){ cin >> a[i]; } for (int i = 1; i <= n; i++){ for (int j = 1; j <= n; j++){ dp[i][j] = -inf; } } for (int i = 1; i <= n; i++){ dp[i][i] = 1; for (int j = 1; j < i; j++){ if (i - j > d) continue; for (int k = 1; k <= j; k++){ if (a[k] < a[i]) dp[i][i] = max(dp[i][i], dp[j][k] + 1); else dp[i][k] = max(dp[i][k], dp[j][k]); } } } int ans = 0; for (int i = 1; i <= n; i++){ ans = max(ans, dp[n][i]); } cout << ans << '\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...