Submission #3013878
Source Code Expand
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(10000)
def read_int():
return int(input())
def read_int_n():
return list(map(int, input().split()))
def read_float():
return float(input())
def read_float_n():
return list(map(float, input().split()))
def read_str():
return input().strip()
def read_str_n():
return list(map(str, input().split()))
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, 'sec')
return ret
return wrap
@mt
def slv(N, X, A):
ans = sys.maxsize
mc = [(sys.maxsize, -1)] * N
for k in range(N):
ac = 0
for i in range(N):
mc[i] = min(mc[i], (A[i-k], k), key=lambda x: x[0])
ac += A[i-mc[i][1]]
ac += k*X
ans = min(ans, ac)
return ans
def main():
N, X = read_int_n()
A = read_int_n()
print(slv(N, X, A))
if __name__ == '__main__':
main()
Submission Info
Submission Time |
|
Task |
B - Colorful Slimes |
User |
patahene |
Language |
PyPy3 (2.4.0) |
Score |
400 |
Code Size |
1497 Byte |
Status |
AC |
Exec Time |
354 ms |
Memory |
62572 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 |
264 ms |
59628 KB |
0_01.txt |
AC |
260 ms |
59628 KB |
0_02.txt |
AC |
258 ms |
59628 KB |
1_00.txt |
AC |
329 ms |
61804 KB |
1_01.txt |
AC |
328 ms |
61804 KB |
1_02.txt |
AC |
329 ms |
61804 KB |
1_03.txt |
AC |
332 ms |
61804 KB |
1_04.txt |
AC |
331 ms |
61804 KB |
1_05.txt |
AC |
329 ms |
61804 KB |
1_06.txt |
AC |
330 ms |
61932 KB |
1_07.txt |
AC |
329 ms |
61932 KB |
1_08.txt |
AC |
336 ms |
61932 KB |
1_09.txt |
AC |
345 ms |
61804 KB |
1_10.txt |
AC |
343 ms |
62316 KB |
1_11.txt |
AC |
354 ms |
62316 KB |
1_12.txt |
AC |
342 ms |
62572 KB |
1_13.txt |
AC |
325 ms |
62188 KB |
1_14.txt |
AC |
349 ms |
62316 KB |
1_15.txt |
AC |
326 ms |
62444 KB |
1_16.txt |
AC |
351 ms |
62316 KB |
1_17.txt |
AC |
348 ms |
62572 KB |