제출 #1282888

#제출 시각아이디문제언어결과실행 시간메모리
1282888tranbahien0Rabbit Carrot (LMIO19_triusis)C++20
0 / 100
2 ms580 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, id[maxn], t[maxn]; vector<int> vals; ll a[maxn]; 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]); 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]) - 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]; a[i] -= 1LL * k * i; } compress(); FOR(i, 1, n) { int x = get(id[i]) + 1; if(x == 1 && a[i] > k) 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...