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>
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) (int(x.size()))
#define all(x) (x).begin(),(x).end()
using namespace std;
int main(){
int n, d;
scanf("%d%d", &n, &d);
vector<int> wej(n+1);
FOR(i, 1, n) scanf("%d", &wej[i]);
vector<int> prawo(n+1);
FOR(i, 1, n){
int ost = i;
prawo[i] = i;
FOR(j, i+1, n){
if(wej[j] <= wej[i]) ost = j;
if(j-ost > d) break;
prawo[i] = j;
}
}
vector<int> dp(n+1, 0);
FOR(i, 1, n){
++dp[i];
FOR(j, i+1, prawo[i]) if(wej[j] > wej[i]) dp[j] = max(dp[j], dp[i]);
}
int wyn = 0;
FOR(i, 1, n) if(prawo[i] == n) wyn = max(wyn, dp[i]);
printf("%d", wyn);
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | scanf("%d%d", &n, &d);
| ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:12:20: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | FOR(i, 1, n) scanf("%d", &wej[i]);
| ~~~~~^~~~~~~~~~~~~~~
# | 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... |