Submission #1350364


Source Code Expand

#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#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)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	LL X;
	cin >> N >> X;
	vector<LL> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	/////
	vector< vector<LL> > dp(N,vector<LL>(N));
	for(int i=0;i<N;++i){
		dp[i][0] = A[i];
		for(int x=1;x<N;++x){
			dp[i][x] = min(dp[i][x-1],A[(i-x+N)%N] );
		}
	}

	LL ans = LINF;
	for(LL K=0;K<N;++K){//K回色変換を使う
		LL res = X*K;
		for(int i=0;i<N;++i){
			res += dp[i][K];
		}
		ans = min(ans,res);
	}
	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 - Colorful Slimes
User akarin55
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1654 Byte
Status AC
Exec Time 88 ms
Memory 31616 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 21
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt
Case Name Status Exec Time Memory
0_00.txt AC 3 ms 384 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 87 ms 31616 KB
1_01.txt AC 87 ms 31616 KB
1_02.txt AC 87 ms 31616 KB
1_03.txt AC 87 ms 31616 KB
1_04.txt AC 87 ms 31616 KB
1_05.txt AC 87 ms 31616 KB
1_06.txt AC 87 ms 31616 KB
1_07.txt AC 88 ms 31616 KB
1_08.txt AC 87 ms 31616 KB
1_09.txt AC 88 ms 31616 KB
1_10.txt AC 63 ms 23168 KB
1_11.txt AC 85 ms 30976 KB
1_12.txt AC 77 ms 28288 KB
1_13.txt AC 52 ms 19584 KB
1_14.txt AC 84 ms 30848 KB
1_15.txt AC 64 ms 23936 KB
1_16.txt AC 73 ms 27520 KB
1_17.txt AC 85 ms 31104 KB