# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1087115 | coldbr3w | Financial Report (JOI21_financial) | C++17 | 2 ms | 604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define pll pair<long long, long long>
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
const ll N = 2000;
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll block = 350;
ll nxt[N], a[N], dp[N];
ll n,d;
void to_thic_cau(){
cin >> n >> d;
for(int i = 1; i <= n;i++) cin >> a[i];
for(int i = 1; i <= n;i++){
ll lst = i;
for(int j = i + 1; j <= n;j++){
if(j - lst > d) break;
if(a[j] <= a[i]) lst = j;
nxt[i] = j;
}
}
ll res = 0;
for(int i = 1; i <= n;i++){
dp[i] = 1;
for(int j = 1; j <= i - 1;j++) if(a[i] > a[j] && nxt[j] >= i) dp[i] = max(dp[i], dp[j] + 1);
res = max(res, dp[i]);
}
cout << res << '\n';
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll tc = 1;
//cin >> tc;
while(tc--) to_thic_cau();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |