結果
| 問題 |
No.275 中央値を求めよ
|
| コンテスト | |
| ユーザー |
_kouhe1
|
| 提出日時 | 2018-11-08 02:09:02 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 1,000 ms |
| コード長 | 393 bytes |
| コンパイル時間 | 274 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-06-25 02:00:29 |
| 合計ジャッジ時間 | 2,646 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
コンパイルメッセージ
Main.py:10: SyntaxWarning: "is" with 'int' literal. Did you mean "=="? if cntDic[str(i)] is 0: Main.py:14: SyntaxWarning: "is" with 'int' literal. Did you mean "=="? if len(sa)%2 is 1:
ソースコード
n=int(input())
a = [int(i) for i in input().split()]
cntDic = {}
sa = []
for i in range(-1000, 1001):
cntDic[str(i)] = 0
for ae in a:
cntDic[str(ae)] += 1
for i in range(-1000, 1001):
if cntDic[str(i)] is 0:
continue
for cnt in range(cntDic[str(i)]):
sa.append(i)
if len(sa)%2 is 1:
print(sa[len(sa)//2])
else:
print((sa[len(sa)//2]+sa[len(sa)//2-1])/2)
_kouhe1