# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1060434 | manhlinh1501 | Rabbit Carrot (LMIO19_triusis) | C++17 | 49 ms | 5596 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int MAXN = 2e5 + 5;
#define ALL(a) (a).begin(), (a).end()
#define LB(a, x) (lower_bound(ALL(a), x) - (a).begin() + 1)
struct fenwick {
int tree[MAXN];
void update(int x, int v) {
x++;
for(; x < MAXN; x += (x & -x))
tree[x] = max(tree[x], v);
}
int calc(int x) {
x++;
int res = 0;
for(; x; x -= (x & -x))
res = max(res, tree[x]);
return res;
}
} BIT;
int N, K;
int a[MAXN];
int b[MAXN];
void compress() {
vector<int> temp;
for(int i = 1; i <= N; i++) temp.emplace_back(a[i]);
sort(ALL(temp));
temp.resize(unique(ALL(temp)) - temp.begin());
for(int i = 1; i <= N; i++) a[i] = LB(temp, a[i]);
}
signed main() {
#define TASK "code"
if (fopen(TASK ".inp", "r")) {
freopen(TASK ".inp", "r", stdin);
freopen(TASK ".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N >> K;
for(int i = 1; i <= N; i++) {
cin >> b[i];
a[i] = i * K - b[i];
b[i] = a[i];
}
compress();
int ans = 0;
for(int i = 1; i <= N; i++) {
if(b[i] >= 0) {
int res = BIT.calc(a[i]) + 1;
ans = max(ans, res);
BIT.update(a[i], res);
}
}
cout << N - ans;
return (0 ^ 0);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |