이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
int main(){
int n, k;
cin>>n>>k;
int a[n];
for(int i=0; i<n; i++){
cin>>a[i];
}
long long ans = INF;
for(int bit=1; bit<int(pow(2, n)); bit++){
if(__builtin_popcount(bit) > k || (bit & 1) == 0) continue;
long long now = a[n-1]-a[0]+1;
for(int i=1; i<n; i++){
if((bit & (1 << i)) > 0){
now -= a[i]-a[i-1]-1;
}
}
ans = min(ans, now);
}
cout<<ans<<endl;
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... |