제출 #1282900

#제출 시각아이디문제언어결과실행 시간메모리
1282900tranbahien0Rabbit Carrot (LMIO19_triusis)C++20
0 / 100
2 ms584 KiB
#include <bits/stdc++.h> #define FOR(i, a, b) for(int i = (a); i <= (b); i++) #define FOD(i, a, b) for(int i = (a); i >= (b); i--) #define file(name) if(fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } #define el cout << '\n' #define maxn int(2e5 + 5) using namespace std; typedef long long ll; int n, k, a[maxn], id[maxn], t[maxn]; vector<ll> vals; void update(int x, int v) { for(; x; x -= x & -x) t[x] = max(t[x], v); } int get(int x) { int res = 0; for(; x <= n; x += x & -x) res = max(res, t[x]); return res; } void compress() { FOR(i, 1, n) vals.push_back(a[i] - 1LL * k * i); sort(vals.begin(), vals.end()); vals.resize(unique(vals.begin(), vals.end()) - vals.begin()); FOR(i, 1, n) id[i] = lower_bound(vals.begin(), vals.end(), a[i] - 1LL * k * i) - vals.begin() + 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; FOR(i, 1, n) cin >> a[i]; compress(); FOR(i, 1, n) { int x = get(id[i]); if(x == 0) x = (a[i] <= k); else x++; update(id[i], x); } cout << n - get(1); 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...