제출 #940314

#제출 시각아이디문제언어결과실행 시간메모리
940314RifalFinancial Report (JOI21_financial)C++14
0 / 100
4054 ms3920 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]; int ans = 0; for(int i = 0; i < n; i++) cin >> arr[i]; for(int i = 0; i < n; i++) { pair<int,int> dp[n]; for(int j = 0; j < n; j++) { dp[j].first = 0; dp[j].second = INF; } dp[i].first = 1; dp[i].second = arr[i]; for(int j = i+1; j < n; j++) { for(int z = 1; z <= d; z++) { if(j-z >= i) { if(dp[j-z].second < arr[j]) { if(dp[j].first < dp[j-z].first+1) { dp[j].first = max(dp[j].first,dp[j-z].first+1); dp[j].second = arr[j]; } else if(dp[j].first == dp[j-z].first+1) { dp[j].second = min(dp[j].second,arr[j]); } } else { if(dp[j].first < dp[j-z].first) { dp[j].first = max(dp[j].first,dp[j-z].first); dp[j].second = dp[j-z].second; } else if(dp[j].first == dp[j-z].first) { dp[j].second = min(max(dp[j].second,arr[j]),dp[j-z].second); } } } else { break; } } } ans = max(ans,dp[n-1].first); } 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...