結果
問題 |
No.2126 MEX Game
|
ユーザー |
![]() |
提出日時 | 2022-11-21 19:09:38 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 745 bytes |
コンパイル時間 | 350 ms |
コンパイル使用メモリ | 41,728 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 10:16:22 |
合計ジャッジ時間 | 1,921 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 9 |
ソースコード
/* -*- coding: utf-8 -*- * * 2126.cc: No.2126 MEX Game - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 100000; const int MAX_A = 100000; /* typedef */ /* global variables */ int as[MAX_N], cs[MAX_A + 1]; /* subroutines */ /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); for (int i = 0; i < n; i++) cs[as[i]]++; int k = 0; while (cs[k] >= 2) k++; //printf("cs[%d] = %d\n", k, cs[k]); if (k == 1) { int l = k + 1; while (cs[l] >= 2) l++; if (cs[l] == 0) l--; //printf("cs[%d] = %d, cs[%d] = %d\n", k, cs[k], l, cs[l]); printf("%d\n", l); } else printf("%d\n", k); return 0; }