Submission #3780777
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;
template<typename T>
void printv(vector<T> const& s) {
REP(i, SZ(s)) {
cout << s[i] << " ";
}
cout << endl;
}
int main () {
cin.tie(0);
cout << setprecision(10);
ll n, x; cin >> n >> x;
vll a(n);
REP(i, n) {
cin >> a[i];
}
vector<vector<pair<ll, int>>> g(n);
REP(i, n) {
g[i].resize(n);
}
REP(i, n) {
REP(j, n) {
if(j < i) g[i][j] = pair<ll, int>(a[j] + x * (i - j), i - j);
if(j == i) g[i][j] = pair<ll, int> (a[j], 0);
if(j > i) g[i][j] = pair<ll, int>(a[j] + x * (i + n - j), i + n - j);
}
}
ll ma = 0;
vll sec(n);
REP(i, n) {
ll mi = LINF;
ll tmp = 0;
REP(j, n) {
if(mi > g[i][j].fi) {
mi = g[i][j].fi;
tmp = g[i][j].se;
sec[i] = a[j];
}
}
ma = max(ma, tmp);
}
ll ans = x * ma;
REP(i, n) {
ans += sec[i];
}
cout << ans << endl;
}
Submission Info
Submission Time |
|
Task |
B - Colorful Slimes |
User |
kanra824 |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
1662 Byte |
Status |
WA |
Exec Time |
45 ms |
Memory |
62848 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 400 |
Status |
|
|
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 |
44 ms |
62848 KB |
1_01.txt |
AC |
44 ms |
62848 KB |
1_02.txt |
AC |
45 ms |
62848 KB |
1_03.txt |
AC |
44 ms |
62848 KB |
1_04.txt |
WA |
44 ms |
62848 KB |
1_05.txt |
AC |
44 ms |
62848 KB |
1_06.txt |
WA |
44 ms |
62848 KB |
1_07.txt |
AC |
44 ms |
62848 KB |
1_08.txt |
WA |
44 ms |
62848 KB |
1_09.txt |
AC |
44 ms |
62848 KB |
1_10.txt |
WA |
33 ms |
46080 KB |
1_11.txt |
WA |
44 ms |
61568 KB |
1_12.txt |
WA |
40 ms |
56320 KB |
1_13.txt |
WA |
28 ms |
38784 KB |
1_14.txt |
WA |
43 ms |
61312 KB |
1_15.txt |
WA |
35 ms |
49664 KB |
1_16.txt |
WA |
39 ms |
54528 KB |
1_17.txt |
WA |
44 ms |
61952 KB |