Submission #619982

#TimeUsernameProblemLanguageResultExecution timeMemory
619982CoolRabbitXTFinancial Report (JOI21_financial)C++14
14 / 100
4075 ms1048576 KiB
#include <bits/stdc++.h> using namespace std; int n, d; vector <int> arr; int current_max; int solve(int indx, int maxi){ vector <int> options; int max_options; options.resize(d+5); int condition; int the_max = 0; if(indx == n) { if(arr[indx] > maxi) return 1; else return 0; } for(int i = 1; i<= d; i++){ if(indx + i >= n) break; else{ if(arr[indx+i] > maxi){ condition = 1; the_max = arr[indx+i]; } else { the_max = maxi; condition = 0; } options[i] = solve(indx + i, the_max) + condition; } } max_options = 0; for(int i = 1; i <=d; i++){ if(options[i] > max_options) max_options = options[i]; } return max_options; } int main(){ cin >> n >> d; arr.resize(n); for(int i = 0; i<n; i++){ cin >> arr[i]; } for(int i = 0; i<n; i++){ //cout << "for indx: " << i << ": " << solve(i, arr[i]) << endl; if(solve(i, arr[i]) > current_max) { current_max = solve(i, arr[i]); } } cout << current_max + 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...