Submission #940630

#TimeUsernameProblemLanguageResultExecution timeMemory
940630RifalFinancial Report (JOI21_financial)C++14
0 / 100
4018 ms7000 KiB
#include <bits/stdc++.h> #include <fstream> #define endl '\n' #define mod 1000000007 #define INF 2000000000 #define INF2 1000000000000000000 ///#define cin fin ///#define cout fout using namespace std; double const EPS = 1e-14; typedef long long ll; ///ofstream fout("herding.out"); ///ifstream fin("herding.in"); int main() { ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); int n, d; cin >> n >> d; int arr[n]; pair<int,int> dp[n]; int ans = 1; for(int i = 0; i < n; i++) cin >> arr[i]; for(int i = 0; i < n; i++) { dp[i].first = 1; dp[i].second = arr[i]; for(int j = 1; j <= d; j++) { if(i-j < 0) break; if(dp[i-j].second < arr[i]) { dp[i].first = max(dp[i].first,dp[i-j].first+1); dp[i].second = arr[i]; } dp[i].first = max(dp[i].first,dp[i-j].first); dp[i].second = max(dp[i-j].second,arr[i]); if(arr[i-j] < arr[i]) { if(dp[i].first < 2) { dp[i].first = 2; dp[i].second = arr[i]; } else if(dp[i].first == 2) { dp[i].second = min(dp[i].second,arr[i]); } } } // cout << i << ' ' << dp[i].first << ' ' << dp[i].second << endl; ans = max(dp[i].first,ans); } cout << ans << 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...