Submission #1213080
Source Code Expand
#include "bits/stdc++.h"
using namespace std;
const int N = 16;
const long long inf = 1e15 + 15;
int n , k;
int arr[N];
long long solve(int pos , int mask , int done){
if(done >= k){
return 0;
}
if(pos > n){
return inf;
}
long long res = inf;
res = min(res , solve(pos + 1 , mask , done));
int last = arr[1];
for(int i = 2 ; i < pos ; ++i){
last = max(last , arr[i]);
if((mask >> i) & 1){
last = max(arr[i] , last + 1);
}
}
res = min(res , solve(pos + 1 , mask | (1 << pos) , done + 1) + max(0 , last + 1 - arr[pos]));
return res;
}
int main(){
scanf("%d %d" , &n , &k);
for(int i = 1 ; i <= n ; ++i){
scanf("%d" , arr + i);
}
printf("%lld\n" , solve(2 , 1 << 1 , 1));
}
Submission Info
Submission Time |
|
Task |
B - Buildings are Colorful! |
User |
rajat1603 |
Language |
C++14 (GCC 5.4.1) |
Score |
90 |
Code Size |
731 Byte |
Status |
WA |
Exec Time |
2 ms |
Memory |
256 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d" , &n , &k);
^
./Main.cpp:29:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d" , arr + i);
^
Judge Result
Set Name |
Sample |
Subtask1 |
Subtask2 |
Subtask3 |
Score / Max Score |
0 / 0 |
0 / 120 |
90 / 90 |
0 / 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 |
256 KB |
sub0_in2.txt |
AC |
1 ms |
256 KB |
sub1_in1.txt |
WA |
2 ms |
256 KB |
sub1_in2.txt |
AC |
2 ms |
256 KB |
sub2_in1.txt |
AC |
1 ms |
256 KB |
sub2_in2.txt |
AC |
1 ms |
256 KB |
sub2_in3.txt |
AC |
1 ms |
256 KB |
sub3_in1.txt |
WA |
2 ms |
256 KB |
sub3_in2.txt |
WA |
2 ms |
256 KB |