Submission #3013877
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 |
Python (3.4.3) |
Score |
0 |
Code Size |
1497 Byte |
Status |
TLE |
Exec Time |
2104 ms |
Memory |
5740 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 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 |
37 ms |
5484 KB |
0_01.txt |
AC |
37 ms |
5356 KB |
0_02.txt |
AC |
37 ms |
5356 KB |
1_00.txt |
TLE |
2104 ms |
5484 KB |
1_01.txt |
TLE |
2104 ms |
5484 KB |
1_02.txt |
TLE |
2104 ms |
5612 KB |
1_03.txt |
TLE |
2104 ms |
5612 KB |
1_04.txt |
TLE |
2104 ms |
5612 KB |
1_05.txt |
TLE |
2104 ms |
5740 KB |
1_06.txt |
TLE |
2104 ms |
5612 KB |
1_07.txt |
TLE |
2104 ms |
5612 KB |
1_08.txt |
TLE |
2104 ms |
5612 KB |
1_09.txt |
TLE |
2104 ms |
5612 KB |
1_10.txt |
TLE |
2104 ms |
5484 KB |
1_11.txt |
TLE |
2104 ms |
5612 KB |
1_12.txt |
TLE |
2104 ms |
5612 KB |
1_13.txt |
TLE |
2104 ms |
5612 KB |
1_14.txt |
TLE |
2104 ms |
5644 KB |
1_15.txt |
TLE |
2104 ms |
5484 KB |
1_16.txt |
TLE |
2104 ms |
5612 KB |
1_17.txt |
TLE |
2104 ms |
5612 KB |