結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2024-05-27 17:42:32 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 671 bytes |
コンパイル時間 | 499 ms |
コンパイル使用メモリ | 30,080 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-20 20:33:53 |
合計ジャッジ時間 | 1,853 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#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;}