Submission #3013834


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):

    r = 0
    for i in range(N):
        c = (sys.maxsize, -1)
        for j in range(N):
            c = min(c, (A[i-j] + j*X, j), key=lambda x: x[0])
        r = max(r, c[1])

    ans = 0
    for i in range(N):
        c = (sys.maxsize, -1)
        for j in range(r+1):
            c = min(c, (A[i-j], j), key=lambda x: x[0])
        ans += A[i-c[1]]

    ans += r*X
    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 0
Code Size 1609 Byte
Status WA
Exec Time 352 ms
Memory 64748 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 10
WA × 11
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 257 ms 59628 KB
0_01.txt AC 256 ms 59628 KB
0_02.txt AC 257 ms 59628 KB
1_00.txt AC 309 ms 62060 KB
1_01.txt AC 309 ms 62060 KB
1_02.txt AC 323 ms 62188 KB
1_03.txt AC 309 ms 62188 KB
1_04.txt WA 312 ms 62572 KB
1_05.txt AC 319 ms 62188 KB
1_06.txt WA 319 ms 62188 KB
1_07.txt AC 322 ms 62188 KB
1_08.txt WA 309 ms 62188 KB
1_09.txt AC 309 ms 62188 KB
1_10.txt WA 316 ms 63596 KB
1_11.txt WA 332 ms 63852 KB
1_12.txt WA 329 ms 63468 KB
1_13.txt WA 312 ms 63468 KB
1_14.txt WA 328 ms 63596 KB
1_15.txt WA 318 ms 63468 KB
1_16.txt WA 319 ms 63468 KB
1_17.txt WA 352 ms 64748 KB