Submission #1503616


Source Code Expand

#include <bits/stdc++.h> 
 
using namespace std;
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const long INF=LONG_MAX;


int main(){
    long N,x;
    cin>>N>>x;
    vector<long>a(N),b(N);
    REP(i,N){
        cin>>a[i];
        b[i]=a[i];
    }
    LL res=INF;

    REP(k,N){
        LL sum=k*x;
        REP(i,N){
            b[i]=min(b[i],a[(i-k+N)%N]);
            sum+=b[i];
        }
        res=min(res,sum);
    }
    cout<<res<<endl;
    return 0;
}
//b[i]=min(a[i],a[i-1],a[i-2],...,a[i-k])

Submission Info

Submission Time
Task B - Colorful Slimes
User blue0620
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1068 Byte
Status AC
Exec Time 46 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 45 ms 256 KB
1_01.txt AC 45 ms 256 KB
1_02.txt AC 46 ms 256 KB
1_03.txt AC 46 ms 256 KB
1_04.txt AC 45 ms 256 KB
1_05.txt AC 45 ms 256 KB
1_06.txt AC 45 ms 256 KB
1_07.txt AC 46 ms 256 KB
1_08.txt AC 45 ms 256 KB
1_09.txt AC 45 ms 256 KB
1_10.txt AC 34 ms 256 KB
1_11.txt AC 45 ms 256 KB
1_12.txt AC 41 ms 256 KB
1_13.txt AC 29 ms 256 KB
1_14.txt AC 44 ms 256 KB
1_15.txt AC 35 ms 256 KB
1_16.txt AC 40 ms 256 KB
1_17.txt AC 45 ms 256 KB