Submission #680299

#TimeUsernameProblemLanguageResultExecution timeMemory
680299ntarsisElection (BOI18_election)Pypy 3
28 / 100
3069 ms28256 KiB
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))
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...