Submission #1519567
Source Code Expand
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <iterator> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <tuple> #include <bitset> #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <fstream> #include <random> //#include <time.h> #include <ctime> #pragma endregion //#include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) #define ALL(X) X.begin(), X.end() ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; typedef std::pair<LL,LL> PLL;// typedef std::pair<int,int> PII;// #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)1e18+20; const double PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; void solve(){ int N,K; cin >> N >> K; vector<LL> A(N); vector<bool> use(N,false); for(int i=0;i<N;++i){ cin >> A[i]; } for(int i=N-K;i<N;++i){ use[i] = true; } LL ans = LINF; do{//見えるものを決めてコストを計算する LL MAX = 0; LL res = 0; for(int i=0;i<N;++i){ if( use[i] ){ if( MAX < A[i] ){ MAX = A[i]; }else{ res += MAX-A[i]+1; MAX = MAX+1; } }else{ if( MAX < A[i] ){//見えちゃう res = LINF; break; } } } ans = min(ans,res); }while( next_permutation(use.begin(),use.end()) ); cout << ans << endl; } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
Submission Info
Submission Time | |
---|---|
Task | B - Buildings are Colorful! |
User | akarin55 |
Language | C++14 (GCC 5.4.1) |
Score | 350 |
Code Size | 1941 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 |