Submission #1691710


Source Code Expand

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (int)1e9+1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する
int N, x;
vector<int> a;
vector<int> b;

//n回魔法使ったときの時間
ll calc(int n) {
    for (int i = 0; i < N; i++) {
        b[i] = min(a[(i - n + N) % N], b[i]);
    }
    return accumulate(b.begin(), b.end(), 0LL) + n * x;
}

int main() {
    cin >> N >> x;
    a = vector<int>(N);
    b = vector<int>(N, INF);
    REP(i, 0, N) cin >> a[i];
    ll cost = calc(0);
    REP(i,1,N){
        cost = min(cost,calc(i));
    }
//    int begin = 0;
//    int end = N;
//    int eps = 2;
//    while (begin + eps < end) {
//        int first = (end - begin) / 3 + begin;
//        int second = end - (end - begin) / 3;
//
//        ll first_calc = calc(first);
//        ll second_calc = calc(second);
//        if (first_calc < second_calc) {
//            end = first;
//        } else {
//            begin = second;
//        }
//
//    }
//
//    ll ans = min({calc(begin), calc(begin + 1), calc(end)});
//
//    cout << ans << endl;

    cout << cost << endl;
    return 0;
}

Submission Info

Submission Time
Task B - Colorful Slimes
User homesentinel
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2396 Byte
Status WA
Exec Time 19 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 9
WA × 12
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 2 ms 256 KB
0_02.txt AC 1 ms 256 KB
1_00.txt AC 18 ms 256 KB
1_01.txt WA 18 ms 256 KB
1_02.txt AC 19 ms 256 KB
1_03.txt WA 19 ms 256 KB
1_04.txt WA 19 ms 256 KB
1_05.txt WA 19 ms 256 KB
1_06.txt WA 19 ms 256 KB
1_07.txt WA 19 ms 256 KB
1_08.txt WA 19 ms 256 KB
1_09.txt WA 19 ms 256 KB
1_10.txt AC 14 ms 256 KB
1_11.txt AC 18 ms 256 KB
1_12.txt WA 17 ms 256 KB
1_13.txt WA 12 ms 256 KB
1_14.txt WA 18 ms 256 KB
1_15.txt AC 15 ms 256 KB
1_16.txt WA 16 ms 256 KB
1_17.txt AC 18 ms 256 KB