Submission #1358049
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vint; typedef pair<int,int> pint; typedef vector<pint> vpint; #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i,n) for(int i=n-1;i>=(0);i--) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) #define all(v) (v).begin(),(v).end() #define eall(v) unique(all(v), v.end()) #define pb push_back #define mp make_pair #define fi first #define se second #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) const int MOD = 1e9 + 7; const int INF = 1e9; const ll INFF = 1e18; ll N, x; ll a[2010]; ll memo[2010]; int main(void) { cin >> N >> x; rep(i, N) cin >> a[i]; rep(i, N){ ll mi = INFF; rep(j, N){ // 移動する回数 ll index = (i - j + N) % N; ll d = a[(i - index + N) % N] + index * x; // printf("j %d d %lld\n", j, d); chmin(mi, d); } // printf("mi %lld\n", mi); memo[i] = mi; } ll ans = 0; rep(i, N) ans += memo[i]; printf("%lld\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Slimes |
User | mmxsrup |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1142 Byte |
Status | WA |
Exec Time | 87 ms |
Memory | 256 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 | WA | 1 ms | 256 KB |
0_02.txt | AC | 1 ms | 256 KB |
1_00.txt | AC | 86 ms | 256 KB |
1_01.txt | AC | 86 ms | 256 KB |
1_02.txt | AC | 87 ms | 256 KB |
1_03.txt | AC | 87 ms | 256 KB |
1_04.txt | WA | 87 ms | 256 KB |
1_05.txt | AC | 87 ms | 256 KB |
1_06.txt | WA | 87 ms | 256 KB |
1_07.txt | AC | 87 ms | 256 KB |
1_08.txt | WA | 87 ms | 256 KB |
1_09.txt | AC | 87 ms | 256 KB |
1_10.txt | WA | 64 ms | 256 KB |
1_11.txt | WA | 85 ms | 256 KB |
1_12.txt | WA | 78 ms | 256 KB |
1_13.txt | WA | 54 ms | 256 KB |
1_14.txt | WA | 84 ms | 256 KB |
1_15.txt | WA | 66 ms | 256 KB |
1_16.txt | WA | 75 ms | 256 KB |
1_17.txt | WA | 85 ms | 256 KB |