# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
880782 | votranngocvy | Rabbit Carrot (LMIO19_triusis) | C++14 | 16 ms | 3820 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
const int N = 1e5 + 5;
vector<int>a;
int bit[N];
void compress() {
vector<pii>vec;
for (int i = 0; i < a.size(); i++) vec.push_back(mp(a[i],i));
sort(vec.begin(),vec.end());
a[vec[0].se] = 1;
for (int i = 1; i < vec.size(); i++)
if (vec[i].fi == vec[i - 1].fi) a[vec[i].se] = a[vec[i - 1].se];
else a[vec[i].se] = i + 1;
}
void update(int i,int x) {
for (; i < N; i += i & (-i)) bit[i] = max(bit[i],x);
}
int get(int i) {
int ans = 0;
for (; i > 0; i -= i & (-i)) ans = max(ans,bit[i]);
return ans;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
if (m * i - x >= 0) a.push_back(m * i - x);
}
int ans = 0;
if (a.size()) {
compress();
for (int i = 0; i < a.size(); i++) {
int tmp = get(a[i]) + 1;
ans = max(ans,tmp);
update(a[i],tmp);
}
}
cout << n - ans << "\n";
}
컴파일 시 표준 에러 (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... |