제출 #534224

#제출 시각아이디문제언어결과실행 시간메모리
534224MonarchuwuFinancial Report (JOI21_financial)C++17
0 / 100
43 ms3268 KiB
#include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int N = 3e5 + 7, N2 = 400 + 2; int n, d; int a[N]; // dp[i][j] -> dp[k][a[j] > a[k] ? j : k] void maximize(int &a, int b) { if (a < b) a = b; } int dp[N2][N2]; void subtask2() { for (int i = 0; i < n; ++i) for (int j = 0; j <= i; ++j) for (int k = i + 1; k <= min(n, i + d); ++k) { if (a[j] < a[k]) maximize(dp[k][k], dp[i][j] + 1); else maximize(dp[k][j], dp[i][j]); } int ans(0); for (int i = 1; i <= n; ++i) maximize(ans, dp[n][i]); cout << ans << '\n'; } int main() { cin.tie(NULL)->sync_with_stdio(false); cin >> n >> d; for (int i = 1; i <= n; ++i) cin >> a[i]; if (n <= 400) subtask2(); } /** /\_/\ * (= ._.) * / >0 \>1 **/
#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...