Submission #874949

#TimeUsernameProblemLanguageResultExecution timeMemory
874949efedmrlrFinancial Report (JOI21_financial)C++17
48 / 100
4101 ms8276 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int #define MP make_pair #define pb push_back #define REP(i,n) for(int (i) = 0; (i)<(n); (i)++) void fastio() { ios_base::sync_with_stdio(false); cin.tie(NULL); } const int N = 1e5+5; const int MOD = 1e9+7; const int INF = 1e12; const int M = 1e6+5; const long double EPS = 0.00001; int n,m,q,d; vector<int> a, dp; signed main() { cin>>n>>d; a.resize(n+1); dp.assign(n + 1, 1); REP(i,n) cin>>a[i + 1]; dp[n] = 1; for(int i = n - 1; i>=1; i--) { int cnt = 0; for(int j = i + 1; j<=n; j++) { cnt++; if(cnt > d) { break; } if(a[j] > a[i]) { dp[i] = max(dp[i], dp[j] + 1); } else { cnt = 0; } } } int ans = 0; for(int i = 1; i<=n; i++) { ans = max(ans ,dp[i]); } cout<<ans<<"\n"; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:8:26: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    8 | #define REP(i,n) for(int (i) = 0; (i)<(n); (i)++)
      |                          ^
Main.cpp:27:5: note: in expansion of macro 'REP'
   27 |     REP(i,n) cin>>a[i + 1];
      |     ^~~
#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...