Submission #1511723
Source Code Expand
#include <algorithm> #include <numeric> #include <numeric> #include <complex> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (lli i = 0; i < (n); i++) #define rrep(i, n) for (lli i = (n)-1; i >= 0; i--) using namespace std; using lli = long long int; lli dp[2005][2005] = {}; int main() { lli n, x, a[2005]; cin >> n >> x; rep(i, n) cin >> a[i]; lli INF = 1e18; rep(i, 2005) rep(j, 2005) dp[i][j] = INF; rep(i, 2005) dp[i][0] = a[i]; rep(i, n) rep(j, n) { dp[i][j + 1] = min(dp[i][j], a[(i - j - 1 + n) % n]); } lli ans = 1e18; rep(j, n + 1) { lli sum = 0; rep(i, n) sum += dp[i][j]; ans = min(sum + j * x, ans); } cout << ans << endl; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Slimes |
User | uenoku |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 846 Byte |
Status | AC |
Exec Time | 61 ms |
Memory | 31616 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 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 | 9 ms | 31616 KB |
0_01.txt | AC | 9 ms | 31616 KB |
0_02.txt | AC | 9 ms | 31616 KB |
1_00.txt | AC | 60 ms | 31616 KB |
1_01.txt | AC | 60 ms | 31616 KB |
1_02.txt | AC | 60 ms | 31616 KB |
1_03.txt | AC | 61 ms | 31616 KB |
1_04.txt | AC | 61 ms | 31616 KB |
1_05.txt | AC | 61 ms | 31616 KB |
1_06.txt | AC | 61 ms | 31616 KB |
1_07.txt | AC | 61 ms | 31616 KB |
1_08.txt | AC | 61 ms | 31616 KB |
1_09.txt | AC | 61 ms | 31616 KB |
1_10.txt | AC | 46 ms | 31616 KB |
1_11.txt | AC | 60 ms | 31616 KB |
1_12.txt | AC | 55 ms | 31616 KB |
1_13.txt | AC | 38 ms | 31616 KB |
1_14.txt | AC | 59 ms | 31616 KB |
1_15.txt | AC | 46 ms | 31616 KB |
1_16.txt | AC | 53 ms | 31616 KB |
1_17.txt | AC | 60 ms | 31616 KB |