結果
問題 |
No.885 アマリクエリ
|
ユーザー |
![]() |
提出日時 | 2021-04-05 02:27:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 917 ms / 2,000 ms |
コード長 | 457 bytes |
コンパイル時間 | 351 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 99,456 KB |
最終ジャッジ日時 | 2024-12-29 14:19:33 |
合計ジャッジ時間 | 6,786 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
import sys input = lambda: sys.stdin.readline().rstrip() from heapq import heappush, heappop H = [] hpush = lambda x: heappush(H, -x) hpop = lambda: -heappop(H) N = int(input()) A = [int(a) for a in input().split()] ans = 0 for a in A: ans += a hpush(a) Q = int(input()) X = [int(a) for a in input().split()] for x in X: while -H[0] >= x: a = hpop() ans -= a a %= x hpush(a) ans += a print(ans)