Submission #1213242
Source Code Expand
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.string; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto K = s[1]; auto A = readln.split.map!(to!long).array; long ans = 1L << 60; foreach (i; 0..(1<<N)) { long h_max = A[0]; int visible = 1; long tmp = 0; foreach (j; 1..N) { if (h_max < A[j]) { h_max = A[j]; visible += 1; } else if (i & (1 << j)) { tmp += h_max - A[j] + 1; h_max = h_max + 1; visible += 1; } } if (visible >= K) ans = min(ans, tmp); } ans.writeln; }
Submission Info
Submission Time | |
---|---|
Task | B - Buildings are Colorful! |
User | nebukuro09 |
Language | D (DMD64 v2.070.1) |
Score | 350 |
Code Size | 873 Byte |
Status | AC |
Exec Time | 3 ms |
Memory | 256 KB |
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 | 256 KB |
sub0_in2.txt | AC | 1 ms | 256 KB |
sub1_in1.txt | AC | 2 ms | 256 KB |
sub1_in2.txt | AC | 3 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 | 2 ms | 256 KB |
sub3_in2.txt | AC | 2 ms | 256 KB |