Submission #3780818


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

  vll dp(n);
  ll ans = 0;
  
  REP(i, n) {
    dp[i] = a[i];
    ans += a[i];
  }

  FOR(i, 1, n) {
    REP(j, n) {
      dp[j] = min(dp[j], a[(j-i+n)%n]);
    }

    ll tmp = x * i;
    REP(j, n) {
      tmp += dp[j];
    }

    ans = min(tmp, ans);
  }

  cout << ans << endl;

  
  
}

Submission Info

Submission Time
Task B - Colorful Slimes
User kanra824
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1316 Byte
Status AC
Exec Time 47 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 21
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 47 ms 256 KB
1_01.txt AC 47 ms 256 KB
1_02.txt AC 47 ms 256 KB
1_03.txt AC 47 ms 256 KB
1_04.txt AC 47 ms 256 KB
1_05.txt AC 47 ms 256 KB
1_06.txt AC 47 ms 256 KB
1_07.txt AC 47 ms 256 KB
1_08.txt AC 47 ms 256 KB
1_09.txt AC 47 ms 256 KB
1_10.txt AC 35 ms 256 KB
1_11.txt AC 46 ms 256 KB
1_12.txt AC 42 ms 256 KB
1_13.txt AC 30 ms 256 KB
1_14.txt AC 46 ms 256 KB
1_15.txt AC 36 ms 256 KB
1_16.txt AC 41 ms 256 KB
1_17.txt AC 47 ms 256 KB