結果
問題 | No.1097 Remainder Operation |
ユーザー | tktk_snsn |
提出日時 | 2020-12-15 23:26:04 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 776 bytes |
コンパイル時間 | 228 ms |
コンパイル使用メモリ | 11,848 KB |
実行使用メモリ | 20,988 KB |
最終ジャッジ日時 | 2023-10-20 06:55:29 |
合計ジャッジ時間 | 5,440 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
10,124 KB |
testcase_01 | AC | 27 ms
10,124 KB |
testcase_02 | AC | 28 ms
10,128 KB |
testcase_03 | AC | 28 ms
10,128 KB |
testcase_04 | AC | 28 ms
10,128 KB |
testcase_05 | AC | 28 ms
10,128 KB |
testcase_06 | RE | - |
testcase_07 | AC | 45 ms
11,052 KB |
testcase_08 | AC | 45 ms
11,052 KB |
testcase_09 | AC | 46 ms
11,052 KB |
testcase_10 | AC | 46 ms
11,052 KB |
testcase_11 | AC | 46 ms
11,052 KB |
testcase_12 | AC | 210 ms
19,384 KB |
testcase_13 | AC | 206 ms
19,384 KB |
testcase_14 | AC | 216 ms
19,384 KB |
testcase_15 | AC | 211 ms
19,384 KB |
testcase_16 | AC | 208 ms
19,384 KB |
testcase_17 | AC | 208 ms
19,384 KB |
testcase_18 | AC | 296 ms
20,988 KB |
testcase_19 | AC | 252 ms
16,236 KB |
testcase_20 | AC | 254 ms
16,236 KB |
testcase_21 | AC | 279 ms
18,612 KB |
testcase_22 | AC | 274 ms
18,612 KB |
ソースコード
from itertools import accumulate import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N = int(input()) A = list(map(int, input().split())) seen = [0] * N first = [0] second = [0] x = 0 while True: i = x % N if seen[i] == 0: first.append(A[i]) x += A[i] seen[i] = 1 elif seen[i] == 1: second.append(A[i]) x += A[i] seen[i] = 2 elif seen[i] >= 2: break F = list(accumulate(first)) S = list(accumulate(second)) LF = len(F) - 1 LS = len(S) - 1 def cnt(k): if k <= len(F): return F[k] res = F[LF] k -= LF d, m = divmod(k, LS) res += d * S[LS] res += S[m] return res Q = int(input()) for _ in range(Q): k = int(input()) print(cnt(k))