Submission #1213100
Source Code Expand
#include <iostream> #include <string> #include <vector> #include <algorithm> 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 = 1e18; for (int i = 0; i < 1 << n; i++) { int cnt = 0; int mx = 0; long long cost = 0; for (int j = 0; j < n; j++) { if (mx >= a[j]) { if (i >> j & 1) { cnt++; cost += mx - a[j] + 1; mx++; } } else { cnt++; mx = a[j]; } } if (cnt >= K) { ans = min(ans, cost); } } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | B - Buildings are Colorful! |
User | pekempey |
Language | C++14 (GCC 5.4.1) |
Score | 350 |
Code Size | 608 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 | 3 ms | 256 KB |
sub3_in2.txt | AC | 2 ms | 256 KB |