/ SeriousOJ /

Record Detail

Memory Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 19ms 3.098 MiB
#2 Accepted 18ms 3.035 MiB
#3 Accepted 18ms 3.07 MiB
#4 Memory Exceeded ≥100ms ≥16.016 MiB
#5 Memory Exceeded ≥100ms ≥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-11-11 02:35:56
Judged By
Score
0
Total Time
≥100ms
Peak Memory
≥16.016 MiB