Submission #1867582


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 2007;
const LD EPS = 1e-7;

LL A[MAXN], S[MAXN];

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	int n;
	LL x, ans = 0, maxs = 0;
	cin >> n >> x;
	REP(i, n)
		cin >> A[i];
	REP(i, n)
	{
		int b = 0;
		FOR(j, 1, n)
		{
			if (A[(i - j + n) % n] + x * max(maxs, S[(i - j + n) % n] + j) <
				A[(i - b + n) % n] + x * max(maxs, S[(i - b + n) % n] + b))
				b = j;
		}
		maxs = max(maxs, S[(i - b + n) % n] + b);
		ans += A[(i - b + n) % n];
	}
	cout << ans + x * maxs;
	//cout << endl; system("pause");
	return 0;
}

Submission Info

Submission Time
Task B - Colorful Slimes
User vjudge3
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1137 Byte
Status WA
Exec Time 29 ms
Memory 256 KB

Judge Result

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