# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
850983 |
2023-09-18T06:09:09 Z |
askow |
Stove (JOI18_stove) |
C++14 |
|
13 ms |
348 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,k;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)cin>>a[i];
if(n<=20){
int ans=1e18;
for(int i=0;i<(1LL<<n);i++){
if(__builtin_popcount(i)>k)continue;
if(__builtin_popcount(i)<k)continue;
int R=0;
int pret=0;
for(int j=0;j<n;j++){
if(i&(1LL<<j)){
// ovde gasim
R+=(a[j]+1)-(a[pret]);
pret=j+1;
}
}
//return 0;
if(i&(1LL<<(n-1))){
//cout<<i<<" "<<R;
//cout<<endl;
ans=min(ans,R);
//cout<<i<<" "<<R;
//cout<<endl;
}
}
cout<<ans;
return 0;
}
priority_queue<pair<int,pair<int,int>>>pq;
pq.push({(a[n-1]+1)-a[0],{0,n-1}});
while(k--){
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
13 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
13 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
13 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |