제출 #423073

#제출 시각아이디문제언어결과실행 시간메모리
423073abdzagFinancial Report (JOI21_financial)C++17
0 / 100
4062 ms7376 KiB
#include<bits/stdc++.h> #include<unordered_map> #define rep(i,a,b) for(int i=int(a);i<int(b);i++) #define rrep(i,a,b) for(int i=int(a);i>int(b);i--) #define trav(a,v) for(auto& a: v) #define sz(v) v.size() #define all(v) v.begin(),v.end() #define vi vector<int> typedef long long ll; typedef long double ld; typedef unsigned long long ull; const long long inf = 1e15; using namespace std; int main() { cin.sync_with_stdio(false); int n,d; cin >> n >> d; vector<pair<ll, int>> v(n); rep(i, 0, n) { cin >> v[i].first; v[i].second = -i; } sort(all(v)); vector<ll> dp(n,-inf); rep(i, 0, n) { dp[-v[i].second] = 1; rrep(j, -v[i].second - 1, max(-1, -v[i].second - 1 - d)) { dp[-v[i].second] = max(dp[-v[i].second], dp[j] + 1); } } ll ans = 1; trav(a, dp)ans = max(ans, a); 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...