Submission #32745228


Source Code Expand

from itertools import accumulate
def main(N, S, W):
    *S, = map(int, S)
    w, s = zip(*sorted(zip(W, S)))
    *s, = accumulate(s)
    data = [w, s]
    
    # i = 0
    ans = data[1][-1]
    
    for i in range(1, N+1):
        if i != N and data[0][i-1] == data[0][i]:
            continue
        c = i - data[1][i-1]
        a = data[1][N-1] - data[1][i-1]
        ans = max(ans, c+a)
    return ans


N = int(input())
S = input()
*W, = map(int, input().split())

print(main(N, S, W))

Submission Info

Submission Time
Task C - Robot Takahashi
User arakaki_tokyo
Language PyPy3 (7.3.0)
Score 300
Code Size 513 Byte
Status AC
Exec Time 667 ms
Memory 155560 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 35
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.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, random_24.txt
Case Name Status Exec Time Memory
example_00.txt AC 74 ms 61968 KiB
example_01.txt AC 57 ms 61948 KiB
example_02.txt AC 54 ms 62100 KiB
hand_00.txt AC 651 ms 154728 KiB
hand_01.txt AC 653 ms 154832 KiB
hand_02.txt AC 666 ms 153876 KiB
hand_03.txt AC 651 ms 154712 KiB
hand_04.txt AC 667 ms 151224 KiB
hand_05.txt AC 54 ms 62088 KiB
hand_06.txt AC 55 ms 62036 KiB
random_00.txt AC 654 ms 154928 KiB
random_01.txt AC 657 ms 155240 KiB
random_02.txt AC 658 ms 155560 KiB
random_03.txt AC 656 ms 155324 KiB
random_04.txt AC 652 ms 155408 KiB
random_05.txt AC 658 ms 155052 KiB
random_06.txt AC 651 ms 155432 KiB
random_07.txt AC 650 ms 155260 KiB
random_08.txt AC 391 ms 147164 KiB
random_09.txt AC 395 ms 146936 KiB
random_10.txt AC 395 ms 150484 KiB
random_11.txt AC 396 ms 150084 KiB
random_12.txt AC 392 ms 147180 KiB
random_13.txt AC 374 ms 144220 KiB
random_14.txt AC 391 ms 153596 KiB
random_15.txt AC 577 ms 153216 KiB
random_16.txt AC 552 ms 142724 KiB
random_17.txt AC 554 ms 143716 KiB
random_18.txt AC 552 ms 141948 KiB
random_19.txt AC 567 ms 154132 KiB
random_20.txt AC 656 ms 154476 KiB
random_21.txt AC 651 ms 154764 KiB
random_22.txt AC 655 ms 155096 KiB
random_23.txt AC 652 ms 154500 KiB
random_24.txt AC 653 ms 155064 KiB