結果

問題 No.2961 Shiny Monster Master
ユーザー okaze
提出日時 2025-01-24 21:36:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 665 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 81,780 KB
実行使用メモリ 105,764 KB
最終ジャッジ日時 2025-01-24 21:37:08
合計ジャッジ時間 10,752 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 1 WA * 76
権限があれば一括ダウンロードができます

ソースコード

diff #

R,N = map(int,input().split())
A =list(map(int,input().split()))
appear = [0]*(R*2)

index = 0
s = 0
for i in range(R*2):
    a = A[index%N]
    if a == i%R:
        s += 1
        index += 1
    appear[i] = s
    
Q = int(input())
for _ in range(Q):
    l,r = map(int,input().split())
    ll = l + (R - (l % R))
    rr = r - (r % R)

    ans = ((rr - ll) // R)*N if ll < rr else 0

    if r < R:
        ln = 0
        if l - 1 > 0:
            ln = appear[l-1]
        rn = appear[r]
        ans += rn - ln
    else:
        ln = 0
        if l - 1 > 0:
            ln = appear[(l-1)%R]
        rn = appear[(R+(r%R))]
        ans += rn -ln
        
    print(ans)
0