結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2015-09-12 13:54:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 1,000 ms |
コード長 | 800 bytes |
コンパイル時間 | 279 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-06-24 23:16:39 |
合計ジャッジ時間 | 2,500 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#!/usr/bin/python3 # This problem is http://yukicoder.me/problems/746 first_line = input() second_line = input() # first_line = '4' # second_line = '5 3 4 7' count = int(first_line) elements = list(map(int, second_line.split(' '))) # XXX: This line is not working. # elements_ordered_by_asc = list(set(elements)) elements_ordered_by_asc = sorted(elements) # print(elements) # print(elements_ordered_by_asc) if count % 2 == 1: # print('Odd number is.') median_index = int(count/2) print(elements_ordered_by_asc[median_index]) else: # print('Even number is.') behind_index = int(count / 2) ahead_index = int(behind_index - 1) # print(behind_index, ahead_index) print((elements_ordered_by_asc[behind_index] + elements_ordered_by_asc[ahead_index]) / 2)