Submission #70460510


Source Code Expand

import sys
from collections import Counter
import numpy as np
# <nonumba> from numba import njit, jit, boolean, int64, float64, typeof

def main():
    from io import StringIO
    execute(StringIO(sample), sys.stderr)
    print("-- ^sample! --", file=sys.stderr)

    execute(sys.stdin, sys.stdout)

    # #<nonumba> if len(solve.nopython_signatures) != 1:
    # #<nonumba>     raise KeyboardInterrupt("!! Unexpected: wrong use of jit !!")

def execute(src, dst):
    N, M, C, = map(int, src.readline().split())
    A = list(map(int, src.readline().split()))
    # nda_1row = np.fromstring(src.readline().strip(), dtype=np.int64, sep=' ')
    cnter = Counter(A)
    BP = list(cnter.items())
    BP.sort()
    B = np.array([b for (b,p) in BP] , dtype=np.int64)
    P = np.array([p for (b,p) in BP] , dtype=np.int64)

    ans = solve(N,M,C,B,P)
    print(ans, file=dst)

sample = """\
5 3 2
1 2 1 0 1
"""

# #<nonumba> @jit(nopython=True, cache=True)
def solve(N,M,C,B,P):
    ans = 0
    G = len(B)
    prevB = -1
    seen = 0
    g = 1
    # stoppedB = 0
    stoppedH = 0
    for startB, startP in zip(B,P) :
        Bdiff = startB - prevB
        stop = False
        if startB == B[0]:
            seen = 0
        else:
            seen += - startP
        while True:
            # nextB = B[g]
            nextP = P[g]
            if C <= seen + nextP:
                while True:
                    if seen == C :
                        stop = True
                        rest = nextP - stoppedH
                        break
                    seen += 1
                    stoppedH += 1
                    continue
            if stop:
                break
            seen += nextP
            stoppedH = 0
            g = ( g + 1 ) % G
        Xi = C + nextP - stoppedH
        ans += Xi * Bdiff
        prevB = startB
        continue
    return ans




main()


Submission Info

Submission Time
Task D - On AtCoder Conference
User tariaki
Language Python (CPython 3.11.4)
Score 0
Code Size 1958 Byte
Status RE
Exec Time 1364 ms
Memory 121536 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 425
Status
WA × 1
RE × 1
WA × 26
RE × 6
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt
Case Name Status Exec Time Memory
example_00.txt WA 86 ms 31928 KiB
example_01.txt RE 85 ms 31824 KiB
hand_00.txt RE 195 ms 90196 KiB
hand_01.txt RE 195 ms 90028 KiB
hand_02.txt WA 1364 ms 121536 KiB
hand_03.txt RE 141 ms 40824 KiB
hand_04.txt RE 87 ms 32040 KiB
hand_05.txt RE 86 ms 31912 KiB
random_00.txt WA 189 ms 70316 KiB
random_01.txt WA 185 ms 70580 KiB
random_02.txt WA 193 ms 70964 KiB
random_03.txt WA 268 ms 89948 KiB
random_04.txt WA 307 ms 90072 KiB
random_05.txt WA 283 ms 89544 KiB
random_06.txt WA 841 ms 88440 KiB
random_07.txt WA 832 ms 90044 KiB
random_08.txt WA 838 ms 90084 KiB
random_09.txt WA 236 ms 86804 KiB
random_10.txt WA 221 ms 90004 KiB
random_11.txt WA 254 ms 89956 KiB
random_12.txt WA 250 ms 89780 KiB
random_13.txt WA 237 ms 93172 KiB
random_14.txt WA 232 ms 89700 KiB
random_15.txt WA 247 ms 90048 KiB
random_16.txt WA 238 ms 86628 KiB
random_17.txt WA 244 ms 89020 KiB
random_18.txt WA 311 ms 88848 KiB
random_19.txt WA 338 ms 86596 KiB
random_20.txt WA 304 ms 93040 KiB
random_21.txt WA 915 ms 93064 KiB
random_22.txt WA 895 ms 92804 KiB
random_23.txt WA 1324 ms 117832 KiB