結果

問題 No.3632 IQR
コンテスト
ユーザー tnakao0123
提出日時 2026-08-23 17:23:16
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 57 ms / 2,000 ms
+ 685µs
コード長 832 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 396 ms
コンパイル使用メモリ 58,544 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-08-23 17:23:23
合計ジャッジ時間 4,917 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 63
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3632.cc:  No.3632 IQR - yukicoder
 */

#include<cstdio>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_N = 400000;

/* typedef */

/* global variables */

int as[MAX_N];

/* subroutines */

double med(int l, int r) {
  int x = (l + r) / 2;
  if ((r - l) & 1) return as[x];
  return (as[x - 1] + as[x]) * 0.5;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  sort(as, as + n);

  double q1 = med(0, n / 2);
  double q2 = med(0, n);
  double q3 = med(n - n / 2, n);
  double iqr = q3 - q1;
  double mina = q1 - 1.5 * iqr;
  double maxa = q3 + 1.5 * iqr;

  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (as[i] < mina || as[i] > maxa) cnt++;

  printf("%.1lf %.1lf %.1lf %d\n", q1, q2, q3, cnt);
  
  return 0;
}

0