제출 #499585

#제출 시각아이디문제언어결과실행 시간메모리
499585gromperenFinancial Report (JOI21_financial)C++14
48 / 100
4072 ms7812 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int INF = 3e5+5; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n, d; cin >> n >> d; vector<int> a(n), b(n), r(n); map<int,int> compress; vector<int> dp(n+1, 1); for (int i = 0; i < n; ++i) { cin >> a[i]; //b[i] = a[i]; } //sort(b.begin(), b.end()); //for (int i =0; i < n; ++i) { //if (!compress[b[i]]) { //compress[b[i]] = compress.size(); //} //} //for (int i = 0; i < n; ++i) { //a[i] = compress[a[i]]; //} //for (int i = 0; i < n; ++i) { //int cnt = 0; //for (int j = i + 1; j < n; ++j) { //if (a[j] <= a[i]) cnt = 0; //else { //cnt++; //if (cnt == d+1) { //r[i] = j; //break; //} //} //} //if (cnt <= d) r[i] = n; //cout << r[i] << " "; //} //cout << endl; int ans = 0; for (int i = 0; i < n; ++i) { int ii = i; for (int j = i - 1; j >= 0; --j) { if (ii - j > d) break; if (a[j] < a[i]) { ii = j; dp[i] = max(dp[i], dp[j]+1); } } ans = max(ans, dp[i]); //cout << dp[i] << " "; } cout << ans << "\n"; 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...