이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(a) a.begin(), a.end()
#define endl "\n"
void printVector(vector<int> a){
for (auto x: a) cout << x << " ";
cout << endl;
}
int max(int x, int y){
if (x > y) return x;
else return y;
}
void solve(){
int n, m; cin >> n >> m;
vector<int> a(n+1);
FOR(i,1,n+1) cin >> a[i];
vector<int> b(n+1);
FOR(i,1,n+1) b[i] = m*i-a[i];
// printVector(b);
vector<int> dp(n+1);
int maxx = 0;
FOR(i,1,n+1){
if (b[i] >= 0){
dp[i] = 1;
FOR(j,1,i){
if (b[j] >= 0 && b[j] <= b[i]) dp[i] = max(dp[i], 1+dp[j]);
}
maxx = max(maxx, dp[i]);
}
}
cout << n-maxx << endl;
// printVector(dp);
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", stdin)
int t = 1; // cin >> t;
while (t--) solve();
}
| # | 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... |