이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define f first
#define s second
#define ent '\n'
#define int long long
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
using namespace std;
typedef long long ll;
const int mx=1e6+12;
const int mod=1e9+7;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
int dp[5001][5001];
int a[mx];
int n,m,k;
void Press_Fn_with_F11(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
for(int x=1;x<=5000;x++){
dp[0][x]=-1e18;
}
dp[0][0]=0;
for(int i=1;i<=n;i++){
for(int x=0;x<=i;x++){
dp[i][x]=-1e18;
if(a[i]<=dp[i-1][x]+m)dp[i][x]=a[i];
if(x>0)dp[i][x]=max(dp[i][x],dp[i-1][x-1]+m);
}
}
for(int i=0;i<=n;i++){
if(dp[n][i]>=0){
cout<<i<<ent;
return;
}
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int Alikhan_abi_crush=1;
// cin>>Alikhan_abi_crush;
while(Alikhan_abi_crush--){
Press_Fn_with_F11();
}
}
| # | 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... |