제출 #423101

#제출 시각아이디문제언어결과실행 시간메모리
423101abdzagFinancial Report (JOI21_financial)C++17
48 / 100
4048 ms7320 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; ll cur = d; rrep(j, -v[i].second - 1,-1) { dp[-v[i].second] = max(dp[-v[i].second], dp[j] + 1); if (dp[j] != -inf)cur = d; else if (!--cur)break; } } 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...