結果
問題 | No.1053 ゲーミング棒 |
ユーザー |
![]() |
提出日時 | 2020-05-15 21:38:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 42 ms / 2,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 932 ms |
コンパイル使用メモリ | 86,976 KB |
実行使用メモリ | 8,576 KB |
最終ジャッジ日時 | 2024-09-19 09:20:01 |
合計ジャッジ時間 | 1,984 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <set> #include <map> using namespace std; typedef long long ll; int N; int A[100000]; set<int> st; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> N; int cnt = 0; int prev = -1; for(int i = 0; i < N; i++){ cin >> A[i]; if(prev != A[i]) { cnt++; prev = A[i]; } st.insert(A[i]); } if(st.size() == cnt){ cout << 0 << endl; }else if(st.size() == cnt-1){ if(A[0] == A[N-1]) cout << 1 << endl; else cout << -1 << endl; }else{ cout << -1 << endl; } }