/ SeriousOJ /

Record Detail

Memory Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 14ms 3.27 MiB
#2 Accepted 14ms 3.023 MiB
#3 Accepted 14ms 2.992 MiB
#4 Memory Exceeded ≥62ms ≥16.016 MiB
#5 Memory Exceeded ≥59ms ≥16.016 MiB

Code

"""
    Author      : Arif Ahmad
    Date        : 
    Algo        : 
    Difficulty  : 
"""
from sys import stdin, stdout

def main():
    n = int(stdin.readline().strip())
    light = stdin.readline().strip()
    r = [int(_)-1 for _ in stdin.readline().strip().split()]
    c = [int(_) for _ in stdin.readline().strip().split()]

    flag = [0 for i in range(n)]
    ans = 0
    tog = 0
    for i in range(n):
        x = ord(light[i]) - 48
        
        if (tog & 1): 
            x = 1 - x
            
        if x == 1:
            tog += 1
            ans += c[i]
            flag[ r[i] ] += 1
            
        if flag[i]:
            tog = max(0, tog-flag[i])
            
    stdout.write(str(ans) + '\n')


if __name__ == '__main__':
    main()

Information

Submit By
Type
Submission
Problem
P1125 Lumina's Light-Out Challenge
Language
Python 3 (Python 3.12.3)
Submit At
2024-10-29 10:58:52
Judged At
2024-10-29 10:58:52
Judged By
Score
0
Total Time
≥62ms
Peak Memory
≥16.016 MiB