結果
問題 |
No.50 おもちゃ箱
|
ユーザー |
![]() |
提出日時 | 2019-01-14 17:24:05 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 609 bytes |
コンパイル時間 | 176 ms |
コンパイル使用メモリ | 82,008 KB |
実行使用メモリ | 54,344 KB |
最終ジャッジ日時 | 2024-06-13 00:28:01 |
合計ジャッジ時間 | 2,882 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 WA * 9 |
ソースコード
N = int(input()) A = list(map(int, input().split(' '))) M = int(input()) B = list(map(int, input().split(' '))) put = [0 for _ in range(N)] used = [0 for _ in range(M)] A = sorted(A, reverse=True) B = sorted(B, reverse=True) for i in range(M): for j in range(N): if put[j] == 0: if 0 <= B[i] - A[j]: B[i] = B[i] - A[j] put[j] = 1 used[i] = 1 if sum(put) == N: for i in range(M): if (i < M-1 and used[i+1] == 0) or (i == M-1 and used[i] == 1): print(i+1) exit(0) else: print(-1)