제출 #870147

#제출 시각아이디문제언어결과실행 시간메모리
870147zwezdinvFinancial Report (JOI21_financial)C++17
5 / 100
94 ms8020 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; #define all(x) x.begin(), x.end() const int N = 3e5; int tr[2 * N]; void upd(int k, int x) { for (k += N, tr[k] = max(tr[k], x); k; k >>= 1, tr[k] = max(tr[k << 1], tr[k << 1 | 1])); } int get(int l, int r) { l = max(l, 0); int res = 0; for (l += N, r += N; l <= r; l >>= 1, r >>= 1) { if (l & 1) res = max(res, tr[l++]); if (~r & 1) res = max(res, tr[r--]); } return res; } signed main() { ios::sync_with_stdio(0); cin.tie(0); int n, d; cin >> n >> d; vector<pair<int, int>> a(n); for (int i = 0; i < n; ++i) { cin >> a[i].first; a[i].second = -i; } sort(a.begin(), a.end()); for (auto [x, id] : a) { id = -id; upd(id, get(id - d, id - 1) + 1); } cout << get(0, n - 1); }
#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...