結果

問題 No.275 中央値を求めよ
コンテスト
ユーザー 綾地寧々
提出日時 2024-05-27 17:42:32
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 671 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 162 ms
コンパイル使用メモリ 39,872 KB
最終ジャッジ日時 2026-02-22 11:43:57
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

int main ( void )
{
	uint16_t n, i;
	int16_t a[1000], sort_temp;
	int16_t sort_min;
	uint16_t sort_min_index;
	uint16_t sorted = 0u;

	scanf("%d", &n);
	for ( i = 0u; i < n; i++ ) {
		scanf("%d", &a[i]);
	}

	while ( sorted < n ) {
		sort_min = 1000;
		for ( i = sorted; i < n; i++ ) {
			if ( sort_min > a[i] ) {
				sort_min = a[i];
				sort_min_index = i;
			}
		}

		sort_temp = a[sort_min_index];
		a[sort_min_index] = a[sorted];
		a[sorted] = sort_temp;

		sorted ++;
	}

	i = n / 2;
	if ( n % 2 ) {
		printf("%d\n", a[i]);
	} else {
		printf("%.1f\n", ((float)a[i] + (float)a[i-1]) / 2);
	}

	return 0;
}
0