Submission #1213104


Source Code Expand

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<functional>
#include<list>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<string.h>
#include<limits.h>
#define int long long
using namespace std;

int ans = LLONG_MAX;
int a, b;
int K[15];
int cost;
void saiki(int c, int d,int e) {//c個目まで見てd個とった 最高の高さはe
	if (c == a) {
		if (d >= b) {
			ans = min(ans, cost);
		}
		return;
	}
	if (K[c] > e) {
		saiki(c + 1, d + 1, K[c]);
	}
	else {
		saiki(c + 1, d, e);
		cost += e - K[c] + 1;
		saiki(c + 1, d + 1, e + 1);
		cost -= e - K[c] + 1;
	}
}
signed main() {
	 scanf("%lld%lld", &a, &b);
	 for (int c = 0; c < a; c++) {
		 scanf("%lld",&K[c]);
	 }
	 saiki(1, 1, K[0]);
	 printf("%lld\n", ans);
}

Submission Info

Submission Time
Task B - Buildings are Colorful!
User naoki2016
Language C++14 (GCC 5.4.1)
Score 350
Code Size 888 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:41:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &a, &b);
                            ^
./Main.cpp:43:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld",&K[c]);
                       ^

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 120 / 120 90 / 90 140 / 140
Status
AC × 2
AC × 2
AC × 3
AC × 9
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 AC 1 ms 256 KB
sub1_in2.txt AC 1 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 AC 1 ms 256 KB
sub3_in2.txt AC 1 ms 256 KB