이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const long long inf = 1e16 + 9;
int n, res;
long long m;
long long a[1000005];
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
int cnt = 0;
for (int i = 1; i <= n; ++i){
long long x; cin >> x;
if (m * i >= x) a[++cnt] = 1LL * m * i - x;
}
vector<long long> f(n + 5, inf);
f[0] = -inf;
for (int i = 1; i <= cnt; ++i){
int k = lower_bound(f.begin(), f.end(), a[i]) - f.begin();
res = max(res, k);
f[k] = a[i];
}
cout << n - res;
return 0;
}
# | 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... |