이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll A[200005];
bool cmp(int i, int j) {
return A[i] <= A[j];
}
int main() {
int n,m;
cin >> n >> m;
for (int i=1; i<=n; i++) {
ll x;
cin >> x;
A[i] = x-m*i;
A[i] = -1*A[i];
}
A[0]=0;
vector<int> L(1,0);
L[1] = 0;
for (int j=1; j<=n; j++) {
if (A[j] < 0) continue;
auto it = lower_bound(L.begin(), L.end(), j, cmp);
if (it == L.end()) {
L.push_back(j);
}
else {
*it = j;
}
}
cout << n+1 - L.size() << "\n";
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... |