Submission #1216717
Source Code Expand
#include<stdio.h>
#include<limits.h>
#define ll long long
ll K[20],cost,ans=LLONG_MAX,a,b,i;
ll min1(ll a,ll b){
if(a<b)
return a;
else
return b;
}
void match(ll c,ll d,ll e){
if(c==a){
if(d>=b){
ans=min1(ans,cost);
}
return ;
}
if(K[c]>e){
match(c+1,d+1,K[c]);
}
else{
match(c+1,d,e);
cost+=(e+1-K[c]);
match(c+1,d+1,e+1);
cost-=(e+1-K[c]);
}
}
int main(){
scanf("%lld%lld",&a,&b);
for(i=0;i<a;i++)
scanf("%lld",&K[i]);
match(1,1,K[0]);
printf("%lld\n",ans);
return 0;
}
Submission Info
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:29:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&a,&b);
^
./Main.cpp:31:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&K[i]);
^
Judge Result
Set Name |
Sample |
Subtask1 |
Subtask2 |
Subtask3 |
Score / Max Score |
0 / 0 |
120 / 120 |
90 / 90 |
140 / 140 |
Status |
|
|
|
|
Set Name |
Test Cases |
Sample |
sub0_in1.txt, sub0_in2.txt |
Subtask1 |
sub1_in1.txt, sub1_in2.txt |
Subtask2 |
sub2_in1.txt, sub2_in2.txt, sub2_in3.txt |
Subtask3 |
sub0_in1.txt, sub0_in2.txt, sub1_in1.txt, sub1_in2.txt, sub2_in1.txt, sub2_in2.txt, sub2_in3.txt, sub3_in1.txt, sub3_in2.txt |
Case Name |
Status |
Exec Time |
Memory |
sub0_in1.txt |
AC |
1 ms |
128 KB |
sub0_in2.txt |
AC |
1 ms |
128 KB |
sub1_in1.txt |
AC |
1 ms |
128 KB |
sub1_in2.txt |
AC |
1 ms |
128 KB |
sub2_in1.txt |
AC |
1 ms |
128 KB |
sub2_in2.txt |
AC |
1 ms |
128 KB |
sub2_in3.txt |
AC |
1 ms |
128 KB |
sub3_in1.txt |
AC |
1 ms |
128 KB |
sub3_in2.txt |
AC |
1 ms |
128 KB |