結果
| 問題 | No.1097 Remainder Operation |
| コンテスト | |
| ユーザー |
prussian_coder
|
| 提出日時 | 2022-04-07 22:41:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 471 bytes |
| 記録 | |
| コンパイル時間 | 219 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 158,080 KB |
| 最終ジャッジ日時 | 2024-11-28 02:13:25 |
| 合計ジャッジ時間 | 13,333 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 TLE * 2 |
ソースコード
N=int(input())
A=[int(x) for x in input().split()]
D=dict()
a=0
t=0
D[0]=(0,0)
p=0
ans = []
while True:
p+=1
a+=A[a%N]
ans.append(a)
if not a%N in D:
D[a%N]=(a,p)
else:
break
cycle = p - D[a%N][1]
score = a - D[a%N][0]
def res(K):
if p>K-1:
print(ans[K-1])
else:
b = a + ((K-p)//cycle)*score
q = p + ((K-p)//cycle)*cycle
while q<K:
q+=1
b+=A[b%N]
print(b)
for _ in range(int(input())):
res(int(input()))
prussian_coder