結果

問題 No.2126 MEX Game
ユーザー chro_96chro_96
提出日時 2022-11-18 23:17:41
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 29,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-20 03:46:37
合計ジャッジ時間 1,380 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int n = 0;
  int a = 0;
  
  int res = 0;
  
  int rem = 0;
  int cnt[100001] = {};
  
  int ans = 0;
  
  res = scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    res = scanf("%d", &a);
    cnt[a]++;
  }
  
  rem = n;
  while (cnt[ans] > 1) {
    rem -= cnt[ans];
    ans++;
  }
  
  if (cnt[ans] > 0 && rem > 1) {
    ans++;
    rem -= cnt[ans];
  }
  
  while (cnt[ans] > 1 && rem > 2) {
    rem -= cnt[ans];
    ans++;
  }
  
  printf("%d\n", ans);
  return 0;
}
0