結果

問題 No.275 中央値を求めよ
ユーザー ABKZABKZ
提出日時 2021-06-10 18:51:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 1,000 ms
コード長 442 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 75,940 KB
最終ジャッジ日時 2023-08-20 04:58:01
合計ジャッジ時間 6,365 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,452 KB
testcase_01 AC 86 ms
71,264 KB
testcase_02 AC 76 ms
71,240 KB
testcase_03 AC 76 ms
71,400 KB
testcase_04 AC 74 ms
71,232 KB
testcase_05 AC 72 ms
71,380 KB
testcase_06 AC 74 ms
70,920 KB
testcase_07 AC 81 ms
75,720 KB
testcase_08 AC 75 ms
71,392 KB
testcase_09 AC 78 ms
75,596 KB
testcase_10 AC 77 ms
75,540 KB
testcase_11 AC 73 ms
71,180 KB
testcase_12 AC 73 ms
71,064 KB
testcase_13 AC 75 ms
71,240 KB
testcase_14 AC 74 ms
71,108 KB
testcase_15 AC 82 ms
75,824 KB
testcase_16 AC 75 ms
71,136 KB
testcase_17 AC 75 ms
71,324 KB
testcase_18 AC 83 ms
75,684 KB
testcase_19 AC 83 ms
75,716 KB
testcase_20 AC 83 ms
75,720 KB
testcase_21 AC 86 ms
75,812 KB
testcase_22 AC 97 ms
75,940 KB
testcase_23 AC 94 ms
75,852 KB
testcase_24 AC 93 ms
75,544 KB
testcase_25 AC 97 ms
75,848 KB
testcase_26 AC 97 ms
75,916 KB
testcase_27 AC 95 ms
75,656 KB
testcase_28 AC 89 ms
71,132 KB
testcase_29 AC 94 ms
75,776 KB
testcase_30 AC 88 ms
71,332 KB
testcase_31 AC 96 ms
75,712 KB
testcase_32 AC 92 ms
75,688 KB
testcase_33 AC 96 ms
75,536 KB
testcase_34 AC 90 ms
75,368 KB
testcase_35 AC 94 ms
75,860 KB
testcase_36 AC 94 ms
75,788 KB
testcase_37 AC 94 ms
75,716 KB
testcase_38 AC 92 ms
75,756 KB
testcase_39 AC 91 ms
75,692 KB
testcase_40 AC 95 ms
75,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))

lower = -1001
upper = 1001

for i in range(N):
  if lower >= A[i] or upper <= A[i]:
    continue
  less = 0
  more = 0
  for j in range(N):
    if A[i] > A[j]:
      less += 1
    elif A[i] < A[j]:
      more += 1
  if less < N / 2 and more < N / 2:
    lower = A[i]
    upper = A[i]
    break
  elif less >= N / 2: #
    upper = A[i]
  else:
    lower = A[i]

print((lower + upper) / 2 )
0