Submission #3780790


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 = 1ll << 50;

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];
  }

  vvll dp(n);
  REP(i, n) {
    dp[i].resize(n);
    dp[i][0] = a[i];
  }

  vvll c(n);
  REP(i, n) {
    c[i].resize(n);
    c[i][0] = a[i];
  }

  REP(i, n) {
    FOR(j, 1, n) {
      dp[i][j] = min(dp[i][j-1], a[(i - j + n) % n] + j * x);
      if(dp[i][j-1] <= a[(i-j+n) % n] + j * x) {
        c[i][j] = c[i][j-1];
      } else {
        c[i][j] = a[(i-j+n) % n];
      }
    }
  }

  // REP(i, n) {
  //   printv(dp[i]);
  // }

  ll ans = LINF;
  REP(i, n) {
    ll su = 0;
    REP(j, n) {
      su += c[j][i];
    }
    ans = min(ans, su + x * 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 1626 Byte
Status WA
Exec Time 169 ms
Memory 62976 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 167 ms 62976 KB
1_01.txt AC 167 ms 62976 KB
1_02.txt AC 168 ms 62976 KB
1_03.txt AC 168 ms 62976 KB
1_04.txt WA 168 ms 62976 KB
1_05.txt AC 168 ms 62976 KB
1_06.txt WA 169 ms 62976 KB
1_07.txt AC 169 ms 62976 KB
1_08.txt WA 169 ms 62976 KB
1_09.txt AC 168 ms 62976 KB
1_10.txt WA 125 ms 46080 KB
1_11.txt WA 164 ms 61696 KB
1_12.txt WA 149 ms 56320 KB
1_13.txt WA 103 ms 38912 KB
1_14.txt WA 163 ms 61440 KB
1_15.txt WA 126 ms 47616 KB
1_16.txt WA 145 ms 54656 KB
1_17.txt WA 167 ms 61952 KB