結果

問題 No.3389 k-Days Later
コンテスト
ユーザー hato336
提出日時 2025-11-28 21:45:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,908 KB
実行使用メモリ 91,568 KB
最終ジャッジ日時 2025-11-28 21:45:23
合計ジャッジ時間 13,776 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 17 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import bisect,sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
q = int(input())
b = [0 for i in range(n+1)]
for i in range(n):
    b[i+1] = b[i] + a[i]
s = sum(a)

for i in range(q):
    y,m,d,k = map(int,input().split())
    x = s * (y-1) + b[m-1] + d-1
    x += k
    

    y = x // s
    x %= s

    m = max(0,bisect.bisect_left(b,x)-1)

    x -= b[m]
    y = y+1
    m = m+1
    d = x+1
    if d > a[m-1]:
        d -= a[m-1]
        m += 1
    if m == n:
        m = 1
        n += 1
    print(y,m,d)


0