답안 #680299

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680299 2023-01-10T14:21:47 Z ntarsis Election (BOI18_election) PyPy 3
28 / 100
3000 ms 28256 KB
n = int(input())
s = input()
q = int(input())
for _ in range(q):
    a,b = map(int,input().split())
    curr_c=0
    curr_t=0
    a-=1
    curr = [1]*n
    for i in range(a,b):
        if s[i]=="C":
            curr_c+=1
            continue
        curr_t+=1
        if curr_t>curr_c:
            curr_t-=1
            curr[i]=0
    b-=1
    curr_c=0
    curr_t=0
    for i in range(b,a-1,-1):
        if s[i]=="C":
            curr_c+=1
            continue
        if curr[i]==0:
            continue
        curr_t+=1
        if curr_t>curr_c:
            curr_t-=1
            curr[i]=0
    print(curr.count(0))
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 24596 KB Output is correct
2 Correct 334 ms 24924 KB Output is correct
3 Correct 371 ms 24004 KB Output is correct
4 Correct 316 ms 24816 KB Output is correct
5 Correct 364 ms 24360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 24596 KB Output is correct
2 Correct 334 ms 24924 KB Output is correct
3 Correct 371 ms 24004 KB Output is correct
4 Correct 316 ms 24816 KB Output is correct
5 Correct 364 ms 24360 KB Output is correct
6 Execution timed out 3069 ms 28256 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 24596 KB Output is correct
2 Correct 334 ms 24924 KB Output is correct
3 Correct 371 ms 24004 KB Output is correct
4 Correct 316 ms 24816 KB Output is correct
5 Correct 364 ms 24360 KB Output is correct
6 Execution timed out 3069 ms 28256 KB Time limit exceeded
7 Halted 0 ms 0 KB -