結果
問題 | No.21 平均の差 |
ユーザー | NakLon131 |
提出日時 | 2022-07-17 17:02:39 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 118 ms / 5,000 ms |
コード長 | 615 bytes |
コンパイル時間 | 104 ms |
コンパイル使用メモリ | 10,964 KB |
実行使用メモリ | 7,960 KB |
最終ジャッジ日時 | 2023-09-12 05:08:31 |
合計ジャッジ時間 | 1,352 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 18 ms
7,960 KB |
testcase_01 | AC | 48 ms
7,912 KB |
testcase_02 | AC | 116 ms
7,812 KB |
testcase_03 | AC | 16 ms
7,952 KB |
testcase_04 | AC | 115 ms
7,824 KB |
testcase_05 | AC | 17 ms
7,796 KB |
testcase_06 | AC | 16 ms
7,808 KB |
testcase_07 | AC | 26 ms
7,788 KB |
testcase_08 | AC | 26 ms
7,780 KB |
testcase_09 | AC | 118 ms
7,812 KB |
ソースコード
# input N = int(input()) K = int(input()) n = [int(input()) for i in range(N)] ans = 0 # 3bitで全探索 for i in range(3**N): g1 = [] g2 = [] g3 = [] x = i for j in range(N): if(x % 3 == 0): g1.append(n[j]) elif(x % 3 == 1): g2.append(n[j]) else: g3.append(n[j]) x //= 3 # 正しいグループかどうか判定 if(len(g1) > 0 and len(g2) > 0 and len(g3) > 0): ave1 = sum(g1) // len(g1) ave2 = sum(g2) // len(g2) ave3 = sum(g3) // len(g3) # 平均3つのうち、最大-最小を更新 ave_l = sorted([ave1, ave2, ave3]) ans = max(ans, (ave_l[2] - ave_l[0])) print(ans)