Submission #1213189
Source Code Expand
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int,int> pii; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(a) (a).begin(),(a).end() #define pb emplace_back #define INF (1LL<<59) #define int ll signed main(){ int n,k; cin>>n>>k; vector<int> a(n); rep(i,n)cin>>a[i]; if(k<=1){ cout<<0<<endl; return 0; } int ans = INF; for(int i=0;i<1<<n;i++){ vector<int> v(n); int num = i; int c=0; rep(j,n){ v[j] = num%2; num/=2; if(v[j]==1)c++; } if(c<k)continue; if(v[0]==0)continue; int tmp = 0; int now = -1; rep(j,v.size()){ if(v[j]==0){ now = max(now,a[j]); continue; } if(a[j]<=now){ tmp+=now-a[j]+1; now = now+1; }else{ now = a[j]; } } ans = min(ans,tmp); } cout<<ans<<endl; }
Submission Info
Submission Time | |
---|---|
Task | B - Buildings are Colorful! |
User | Yazaten |
Language | C++14 (GCC 5.4.1) |
Score | 350 |
Code Size | 1073 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 | 3 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 | 3 ms | 256 KB |