Submission #1350346


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<LL> org(N);//iを得るための元
	vector<LL> time(N,0);//iに変えるXの回数
	for(int i=0;i<N;++i){
		LL res = LINF;//iを得るための最短時間
		LL num = i;//iを得るための元
		LL Xnum = 0;//色変化回数
		for(int x=0;x<N;++x){//xも小さいほうが良い
			LL No = (i-x+N)%N;//元
			LL temp = A[No] + x* X;
			if( temp < res ){
				res = temp;
				num = No;
				Xnum = x;
			}
		}
		org[i] = num;
		time[i] = Xnum;
	}
	LL ans = 0;
	LL maxX = 0;
	for(int i=0;i<N;++i){
		ans += A[ org[i] ];
		maxX = max(maxX,time[i]);
	}
	ans = ans + maxX * X;
	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 0
Code Size 1930 Byte
Status WA
Exec Time 16 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 10
WA × 11
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 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 16 ms 256 KB
1_01.txt AC 16 ms 256 KB
1_02.txt AC 16 ms 256 KB
1_03.txt AC 16 ms 256 KB
1_04.txt WA 16 ms 256 KB
1_05.txt AC 16 ms 256 KB
1_06.txt WA 16 ms 256 KB
1_07.txt AC 16 ms 256 KB
1_08.txt WA 16 ms 256 KB
1_09.txt AC 16 ms 256 KB
1_10.txt WA 12 ms 256 KB
1_11.txt WA 16 ms 256 KB
1_12.txt WA 15 ms 256 KB
1_13.txt WA 11 ms 256 KB
1_14.txt WA 16 ms 256 KB
1_15.txt WA 13 ms 256 KB
1_16.txt WA 14 ms 256 KB
1_17.txt WA 16 ms 256 KB