Submission #530730

#TimeUsernameProblemLanguageResultExecution timeMemory
530730MounirFinancial Report (JOI21_financial)C++14
48 / 100
4096 ms7244 KiB
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define pb push_back
#define pii pair<int, int>
#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
#define x first
#define y second
#define int long long
using namespace std;

signed main(){
      int nVals, d; cin >> nVals >> d; //d = 1.
      vector<int> vals(nVals);
      for (int& val : vals)
            cin >> val;
      int dp[nVals], representant[nVals];
      representant[0] = 0, dp[0] = 1;
      int m = 1;
      for (int i = 1; i < nVals; ++i){
            representant[i] = i;
            dp[i] = 1;
          //  cout << "wsh " << i << endl;
            for (int j = 0; j < i; ++j){
                  if (vals[i - 1] <= vals[j])
                        representant[j] = i - 1;
                  if ((i - representant[j]) <= d && vals[i] > vals[j])
                        chmax(dp[i], dp[j] + 1);
                  else if ((i - representant[j]) > d)
                        dp[j] = 0;
               //   cout << dp[j] << " ";
            }
      //      cout << endl;
         //   cout << dp[i] << " " << representant[i] << endl;
            chmax(m, dp[i]);
      }
      //cout << endl;
      cout << m << endl;
      return 0;   
}
#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...