제출 #961124

#제출 시각아이디문제언어결과실행 시간메모리
961124vjudge1Financial Report (JOI21_financial)C++17
0 / 100
4096 ms23888 KiB
#include<bits/stdc++.h> #define INF 1e9 #define fi first #define se second #define FOR(i, k, n) for(int i = k; i <= n; i++) #define FOR1(i, k, n) for(int i = k; i >= n; i--) #define pb push_back #define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define vi vector<int> #define pii pair<int, int> #define vii vector<pii> #define ll long long #define vll vector<ll> #define pll pair<ll, ll> #define re return 0 #define mii map<int, int> #define input "DANCE.inp" #define output "DANCE.out" #define rf freopen(input, "r", stdin); freopen(output, "w", stdout) using namespace std; const int maxn = 3e5 + 5; const int mod = 1e9 + 7; pll T[maxn * 4]; int a[maxn]; int dp[maxn]; void update(int id, int l, int r, int pos, int val, int val1) { if(l == r) { T[id].fi = val; T[id].se = val1; return; } int mid = (l + r) / 2; if(pos <= mid) update(id * 2, l, mid, pos, val, val1); else update(id * 2 + 1, mid + 1, r, pos, val, val1); T[id].fi = max(T[id * 2].fi, T[id * 2 + 1].fi); T[id].se = max(T[id * 2].se, T[id * 2 + 1].se); } int get(int id, int l, int r, int u, int v, int val) { if(l > v || r < u) return 0; if(l >= u && r <= v && T[id].se < val) return T[id].fi; if(l == r) return 0; int mid = (l + r) / 2; return max(get(id * 2, l, mid, u, v, val), get(id * 2 + 1, mid + 1, r, u, v, val)); } int main() { fastio; int n, d; cin >> n >> d; FOR(i, 1, n) cin >> a[i]; dp[1] = 1; update(1, 1, n, 1, dp[1], a[1]); FOR(i, 2, n) { int res = get(1, 1, n, max(1, i - d), i - 1, a[i]); dp[i] = res + 1; update(1, 1, n, i, dp[i], a[i]); } int ans = 0; FOR(i, 1, n) ans = max(ans, dp[i]); cout << ans; re; }
#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...