結果

問題 No.3389 k-Days Later
コンテスト
ユーザー yt142857
提出日時 2025-11-21 10:32:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 569 ms / 2,000 ms
コード長 451 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 82,208 KB
実行使用メモリ 91,840 KB
最終ジャッジ日時 2025-11-28 20:58:37
合計ジャッジ時間 21,235 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import bisect
n = int(input())
s = [int(_) for _ in input().split()]
year = sum(s)
rui = [0]
for i in s:
	rui.append(rui[-1]+i)
q = int(input())
def n_to_d(a):
  nibu = bisect.bisect_left(rui,a)
  return (nibu,a-rui[nibu-1])
def d_to_n(a):
  a,b = a[0],a[1]
  return rui[a-1]+b
for _ in range(q):
	a,b,c,d = map(int,input().split())
	a += d//year
	d = d%year
	num = d_to_n((b,c))+d
	if num>year:
	  num-=year
	  a += 1
	b,c = n_to_d(num)
	print(a,b,c)
0