結果
問題 | No.1053 ゲーミング棒 |
ユーザー |
|
提出日時 | 2020-05-15 21:55:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 32 ms / 2,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 669 ms |
コンパイル使用メモリ | 70,272 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-19 09:49:16 |
合計ジャッジ時間 | 2,176 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<vector> using namespace std; int N; bool ex[1<<17]; main() { cin>>N; vector<pair<int,int> >A; int pre; int cnt=0; for(int i=0;i<N;i++) { int a;cin>>a; if(i==0||pre!=a) { A.push_back(make_pair(a,1)); pre=a; if(ex[a])cnt++; ex[a]=true; } else A.back().second++; } if(!cnt)cout<<0<<endl; else cout<<(cnt==1&&A[0].first==A.back().first?1:-1)<<endl; }