結果

問題 No.3389 k-Days Later
コンテスト
ユーザー detteiuu
提出日時 2025-11-28 21:31:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 223 ms
コンパイル使用メモリ 82,420 KB
実行使用メモリ 96,364 KB
最終ジャッジ日時 2025-11-28 21:32:06
合計ジャッジ時間 16,053 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from bisect import bisect_left, bisect_right

N = int(input())
D = list(map(int, input().split()))
Q = int(input())
query = [list(map(int, input().split())) for _ in range(Q)]

def encode(m, d):
    return cum[m-1]+(d-1)
def decode(n):
    b = bisect_right(cum, n)-1
    return b+1, n-cum[b]+1

total = sum(D)
cum = [0]
for d in D:
    cum.append(cum[-1]+d)

for y, m, d, k in query:
    n = encode(m, d)
    nex = (n+k)%total
    nm, nd = decode(nex)
    ny = y+(k//total)
    if 1 <= (n+k%total)//total:
        ny += 1
    print(ny, nm, nd)
0