Submission #1213068
Source Code Expand
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); for(int i=0; i<n; ++i) cin >> a[i]; long long ans = LLONG_MAX; for(int i=0; i<(1<<n); ++i){ bitset<15> bs(i); if(bs.count() != k) continue; long long cost = 0; int h = 0; for(int i=0; i<n; ++i){ if(bs[i]){ cost += max(0, h + 1 - a[i]); h = max(h+1, a[i]); } else{ h = max(h, a[i]); } } ans = min(ans, cost); } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Buildings are Colorful! |
User | mamekin |
Language | C++14 (GCC 5.4.1) |
Score | 350 |
Code Size | 1116 Byte |
Status | AC |
Exec Time | 1 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 | 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 |