結果
問題 | No.200 カードファイト! |
ユーザー | rpy3cpp |
提出日時 | 2015-07-20 01:06:03 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,703 bytes |
コンパイル時間 | 88 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-08 10:28:03 |
合計ジャッジ時間 | 1,811 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 33 ms
10,880 KB |
testcase_03 | AC | 29 ms
11,008 KB |
testcase_04 | AC | 29 ms
11,008 KB |
testcase_05 | AC | 30 ms
10,880 KB |
testcase_06 | WA | - |
testcase_07 | AC | 31 ms
10,880 KB |
testcase_08 | AC | 30 ms
10,880 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 30 ms
10,880 KB |
testcase_14 | AC | 31 ms
10,880 KB |
testcase_15 | AC | 29 ms
10,880 KB |
testcase_16 | AC | 29 ms
10,880 KB |
testcase_17 | AC | 29 ms
11,008 KB |
testcase_18 | AC | 30 ms
10,880 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 30 ms
11,136 KB |
testcase_22 | AC | 30 ms
11,008 KB |
testcase_23 | AC | 30 ms
11,008 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 29 ms
11,008 KB |
testcase_27 | AC | 29 ms
10,880 KB |
testcase_28 | WA | - |
ソースコード
def read_data(): N = int(input()) A = int(input()) Bs = list(map(int, input().split())) C = int(input()) Ds = list(map(int, input().split())) return N, A, Bs, C, Ds def solve(N, A, Bs, C, Ds): Bs.sort() Ds.sort() minA = min(Bs) maxA = max(Bs) minC = min(Ds) maxC = max(Ds) if minA > maxC: return N if maxA < minC: return 0 if C >= A: return solve_C_is_longer(N, A, Bs, C, Ds) else: return solve_A_is_longer(N, A, Bs, C, Ds) def solve_C_is_longer(N, A, Bs, C, Ds): repeat, residue = divmod(N, C) Cs = Ds * repeat + Ds[:residue] repeat, residue = divmod(N, A) n_win = 0 for r in range(repeat): subCs = Cs[r*A:(r+1)*A] n_win += count_wins(Bs, subCs) if residue: subCs = Cs[-residue:] subAs = Bs[-residue:] n_win += count_wins(subAs, subCs) return n_win def solve_A_is_longer(N, A, Bs, C, Ds): Bs.sort(reverse=True) repeat, residue = divmod(N, A) As = Bs * repeat + Bs[:residue] repeat, residue = divmod(N, C) n_win = 0 for r in range(repeat): subAs = As[r*C:(r+1)*C] n_win += count_wins(subAs, Ds) if residue: subAs = As[-residue:] subCs = Ds[:residue] n_win += count_wins(subAs, subCs) return n_win def count_wins(As, Cs): N = len(As) Acopy = As[:] Ccopy = Cs[:] Acopy.sort() Ccopy.sort() idxA = 0 n_win = 0 for c in Ccopy: while Acopy[idxA] <= c: idxA += 1 if idxA == N: return n_win n_win += 1 return n_win N, A, Bs, C, Ds = read_data() print(solve(N, A, Bs, C, Ds))