結果
問題 | No.885 アマリクエリ |
ユーザー | stng |
提出日時 | 2022-08-08 13:53:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 979 ms / 2,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 302 ms |
コンパイル使用メモリ | 81,804 KB |
実行使用メモリ | 93,708 KB |
最終ジャッジ日時 | 2023-10-19 04:04:48 |
合計ジャッジ時間 | 7,585 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 979 ms
92,580 KB |
testcase_01 | AC | 426 ms
93,672 KB |
testcase_02 | AC | 248 ms
93,708 KB |
testcase_03 | AC | 100 ms
93,208 KB |
testcase_04 | AC | 100 ms
92,680 KB |
testcase_05 | AC | 93 ms
92,108 KB |
testcase_06 | AC | 87 ms
90,060 KB |
testcase_07 | AC | 70 ms
86,352 KB |
testcase_08 | AC | 84 ms
85,296 KB |
testcase_09 | AC | 474 ms
93,672 KB |
testcase_10 | AC | 40 ms
53,544 KB |
testcase_11 | AC | 41 ms
53,544 KB |
testcase_12 | AC | 40 ms
53,544 KB |
testcase_13 | AC | 99 ms
76,188 KB |
testcase_14 | AC | 101 ms
76,072 KB |
testcase_15 | AC | 101 ms
76,336 KB |
testcase_16 | AC | 50 ms
61,148 KB |
testcase_17 | AC | 64 ms
66,032 KB |
testcase_18 | AC | 91 ms
75,944 KB |
testcase_19 | AC | 44 ms
55,592 KB |
testcase_20 | AC | 49 ms
61,148 KB |
testcase_21 | AC | 44 ms
53,544 KB |
ソースコード
import heapq n = int(input()) a = [int(i) for i in input().split()] q = int(input()) x = [int(i) for i in input().split()] qry = x[0] li = [] heapq.heapify(li) now = 0 for i in range(n): tmp = a[i] % qry if tmp != 0: now += tmp heapq.heappush(li,-tmp) print(now) for i in range(q-1): qry = x[i+1] f = True while len(li) and f == True: tmp = heapq.heappop(li) if -tmp >= qry: now -= -tmp tmp = (-tmp) % qry now += tmp if tmp != 0: heapq.heappush(li,-tmp) else: f = False heapq.heappush(li,tmp) print(now)