Submission #850925

# Submission time Handle Problem Language Result Execution time Memory
850925 2023-09-17T19:52:15 Z askow Stove (JOI18_stove) C++14
20 / 100
39 ms 436 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;
            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;
    }
}
//011
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 39 ms 436 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 39 ms 436 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 39 ms 436 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Incorrect 1 ms 348 KB Output isn't correct
11 Halted 0 ms 0 KB -