# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502140 | EliteCallsYou | K blocks (IZhO14_blocks) | C++17 | 1085 ms | 296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# include <bits/stdc++.h>
using namespace std ;
//############################################################################
# define read(a)/**/for(int i=0;i<int(sizeof(a)/sizeof(a[0]));i++){cin>>a[i];}
# define print(x)/**/for(auto zx:x){cout<<zx<<' ';}
const char* tochar(string a){return a.c_str();}
void files(){freopen("planting.in","r",stdin);freopen("planting.out","w",stdout);}
void speed(){ios_base::sync_with_stdio(false);cin.tie(0);}
long long gcd(long long a,long long b){if(!b){return a;}a%=b;return gcd(b,a);}
long long lcm(long long a,long long b){return a /gcd(a,b) * b;}
//###########################################################################
const int N = 1e5 + 5 ;
const long long MOD = 1e9+7 ;
//###########################################################################
void hack(){}
//###########################################################################
int n, m, mn = 1e9 ;
vector < int > vc ;
int ar[10005] ;
void rec( int pos, int k ){
if ( !k ){
vc.push_back(n-1) ;
int cur = 0, sum = 0, pos = 0 ;
for ( int i = 0 ; i < n ; i ++ ){
cur = max(cur,ar[i]) ;
if ( i == vc[pos] ){
sum += cur ;
cur = 0 ;
pos ++ ;
}
}
mn = min(mn,sum) ;
vc.pop_back() ;
return ;
}
for ( int i = pos ; i < n-1 ; i ++ ){
vc.push_back(i) ;
rec(i+1,k-1) ;
vc.pop_back() ;
}
}
int main(){
cin >> n >> m ;
for ( int i = 0 ; i < n ; i ++ ){
cin >> ar[i] ;
}
rec(0,m-1) ;
cout << mn << '\n' ;
}
Compilation message (stderr)
# | 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... |