이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n,m;
cin>>n>>m;
int a[n+5],b[n+5];
a[0]=0;
for(int i=1;i<=n;i++){
cin>>a[i];
}
int ans=n;
for(int i=0;i<(1<<n);i++){
fill(b,b+n+1,0);
int dif=0;
bool ok=true;
for(int j=0;j<n;j++){
if(i&(1<<j)){
b[j+1]=1;
dif++;
}
}
int last=0;
for(int j=1;j<=n;j++){
if(b[j]==0){
if(a[j]>a[last]+m*(j-last)){
ok=false;
break;
}
last=j;
}
}
if(ok){
ans=min(ans,dif);
}
}
cout<<ans;
}
| # | 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... |