제출 #493578

#제출 시각아이디문제언어결과실행 시간메모리
493578600MihneaFinancial Report (JOI21_financial)C++17
48 / 100
4062 ms3048 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 300000 + 7; int n; int d; int a[N]; int dp[N]; int order[N]; bool cmp(int i, int j) { if (a[i] != a[j]) { return a[i] > a[j]; } else { return i < j; } } signed main() { ios::sync_with_stdio(0); cin.tie(0); //freopen ("TonyStark", "r", stdin); cin >> n >> d; for (int i = 1; i <= n; i++) { cin >> a[i]; order[i] = i; } sort(order + 1, order + n + 1, cmp); for (int it = 1; it <= n; it++) { int i = order[it]; dp[i] = 0; int bigger = 0; for (int j = i + 1; j <= n; j++) { dp[i] = max(dp[i], dp[j]); if (a[j] > a[i]) { bigger++; } else { bigger = 0; } if (bigger == d) { break; } } dp[i]++; } int sol = 0; for (int i = 1; i <= n; i++) { sol = max(sol, dp[i]); } cout << sol << "\n"; }
#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...