Submission #1035181

#TimeUsernameProblemLanguageResultExecution timeMemory
1035181May27_thFinancial Report (JOI21_financial)C++17
0 / 100
4091 ms4700 KiB
#include<bits/stdc++.h> using namespace std; #define i64 long long #define mp make_pair #define pb push_back #define all(x) (x).begin(), (x).end() const int INF = 1e9; void Maximize(pair<int, int> &a, pair<int, int> b) { if (a.first < b.first) a = b; else if (a.first == b.first) a.second = min(a.second, b.second); } void Solve(void) { int N, D; cin >> N >> D; vector<int> a(N + 1); for (int i = 1; i <= N; i ++) cin >> a[i]; int ans = 0; for (int st = 1; st <= N; st ++) { vector<pair<int, int>> lis; for (int i = st; i <= N; i ++) { if (lis.empty()) lis.pb(mp(a[i], i)); else { auto it = lower_bound(all(lis), mp(a[i], 0)); if (it == lis.end()) { it --; if ((*it).second + D >= i) lis.pb(mp(a[i], i)); } else { if (it == lis.begin()) { (*it) = mp(a[i], i); } else { auto prev = it; prev --; if ((*prev).second + D >= i) (*it) = mp(a[i], i); else { (*it).second = i; } } } } // cout << i << " " << (int)lis.size() << "\n"; // for (auto [x, id] : lis) { // cout << "(" << x << "," << id << ")" << "\n"; // } } ans = max(ans, (int)lis.size()); } cout << ans << "\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10); int Tests = 1; // cin >> Tests; while (Tests --) { Solve(); } }
#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...