結果
問題 | No.472 平均順位 |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:08:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,697 ms / 2,000 ms |
コード長 | 1,513 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 81,924 KB |
実行使用メモリ | 90,904 KB |
最終ジャッジ日時 | 2025-03-20 21:09:22 |
合計ジャッジ時間 | 10,047 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
def main():import sysinput = sys.stdin.read().split()idx = 0N = int(input[idx])idx += 1P = int(input[idx])idx += 1a_list = []b_list = []c_list = []for _ in range(N):a = int(input[idx])idx += 1b = int(input[idx])idx += 1c = int(input[idx])idx += 1a_list.append(a)b_list.append(b)c_list.append(c)INF = float('inf')current = [INF] * (P + 1)current[0] = 0.0for i in range(N):a = a_list[i]b = b_list[i]c = c_list[i]remaining = (N - 1) - i # Remaining contests after this onemin_s_new = max(0, P - 3 * remaining)next_dp = [INF] * (P + 1)for s_prev in range(P + 1):if current[s_prev] == INF:continuefor x in 0, 1, 2, 3:s_new = s_prev + xif s_new > P:continueif s_new < min_s_new:continueif x == 3:rank = 1elif x == 0:rank = aelif x == 1:rank = belse:rank = cif current[s_prev] + rank < next_dp[s_new]:next_dp[s_new] = current[s_prev] + rankcurrent = next_dpprint("{0:.10f}".format(current[P] / N))if __name__ == '__main__':main()