結果
| 問題 |
No.2931 Shibuya 109
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-12 16:24:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 730 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 205,448 KB |
| 最終ジャッジ日時 | 2024-10-12 16:24:12 |
| 合計ジャッジ時間 | 6,926 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | WA * 1 TLE * 1 -- * 9 |
ソースコード
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] == 0:
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 + 1
print(ans)