結果
問題 | No.2931 Shibuya 109 |
ユーザー |
|
提出日時 | 2024-10-12 16:24:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 436 ms / 4,000 ms |
コード長 | 726 bytes |
コンパイル時間 | 363 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 167,664 KB |
最終ジャッジ日時 | 2024-10-12 16:25:02 |
合計ジャッジ時間 | 7,005 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) input = sys.stdin.readline #n = int(input()) #alist = list(map(int,input().split())) #alist = [] #s = input() n,q = map(int,input().split()) #for i in range(n): # alist.append(list(map(int,input().split()))) a = list(map(int,input().split())) o = [] for i in range(n): if a[i] == 1: o.append(i) b = [1 if a[i] == 9 else 0 for i in range(n)] b = list(itertools.accumulate(b)) + [0] for i in range(q): l,r = map(lambda x:int(x)-1,input().split()) ans = b[r] - b[l-1] for j in o: if l <= j <= r: ans += r - j print(ans)