結果
問題 | No.2126 MEX Game |
ユーザー |
|
提出日時 | 2022-11-18 21:51:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 460 bytes |
コンパイル時間 | 530 ms |
コンパイル使用メモリ | 65,784 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-20 02:14:41 |
合計ジャッジ時間 | 1,725 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N,A[1<<17]; int cnt[1<<17]; main() { cin>>N; for(int i=0;i<N;i++)cin>>A[i]; int rest=0; for(int i=0;i<N;i++) { if(cnt[A[i]]<2)cnt[A[i]]++; else rest++; } int id=0; while(cnt[id]==2)id++; if(cnt[id]==0)cout<<id<<endl; else { if(rest>0)cnt[id]++; else { int t=(1<<17)-1; while(cnt[t]==0)t--; cnt[t]--; cnt[id]++; } while(cnt[id]==2)id++; cout<<id<<endl; } }