# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
675470 | cpLover22 | Rabbit Carrot (LMIO19_triusis) | C++17 | 71 ms | 4780 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5+5;
int n, m, h[N], f[N];
void upd(int u, int v) {
for (; u <= n+1; u += u&-u)
f[u] = max(f[u], v);
}
int get(int u) {
int ans = 0;
for (; u > 0; u -= u&-u)
ans = max(ans, f[u]);
return ans+1;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("Rabbit.inp", "r"))
freopen("Rabbit.inp", "r", stdin),
freopen("Rabbit.out", "w", stdout);
cin >> n >> m;
vector<int> comp;
for (int i = 1; i <= n; ++i)
cin >> h[i];
for (int i = 0; i <= n; ++i)
h[i] = h[i] - m*i,
comp.emplace_back(h[i]);
sort(comp.begin(), comp.end());
comp.erase(unique(comp.begin(), comp.end()), comp.end());
int res = 0;
for (int i = n; i >= 0; --i) {
int v = lower_bound(comp.begin(), comp.end(), h[i]) - comp.begin() + 1;
int cur = get(v); upd(v, cur);
if (!i) return cout << n+1-cur, 0;
}
return 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... |