# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1257778 | ilovewaguri | Financial Report (JOI21_financial) | C++20 | 4094 ms | 2072 KiB |
#include<bits/stdc++.h>
using namespace std;
#define NAME ""
#define nl '\n'
#define allof(x) x.begin(),x.end()
#define allof1(x) x.begin()+1,x.end()
#define allofa(x,sz) x,x+sz+1
#define mset(x,val) memset(x,val,sizeof(x))
#define couf(x) cout << fixed << setprecision(x)
template<class X,class Y> bool minimize(X &a, Y b){if(a>b) {a=b;return true;}return false;};
template<class X,class Y> bool maximize(X &a, Y b){if(a<b) {a=b;return true;}return false;};
typedef long long ll;
const ll mod = (long long)1e9+7;
const int INF = (int)1e9;
const int MAXN = (int)3e5+5;
int a[MAXN],dp[MAXN];
int n,d;
void ccps() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen(NAME".inp","r")) {
freopen(NAME".inp","r",stdin);
freopen(NAME".out","w",stdout);
}
}
signed main() {
ccps();
cin >> n >> d;
int res = 1;
for (int i = 1; i<=n; i++) {
cin >> a[i];
}
for (int i = 1; i<=n; i++) {
dp[i]=1;
int cnt = 0;
for (int j = i-1; j>0; j--) {
if(a[i]<=a[j]) continue;
int num = (i-j-1)/d;
if(cnt>=num) maximize(dp[i],dp[j]+1);
cnt+=(a[i]>a[j]);
}
maximize(res,dp[i]);
}
cout << res;
}
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... |