結果
問題 |
No.2518 Adjacent Larger
|
ユーザー |
![]() |
提出日時 | 2023-10-27 21:26:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 724 bytes |
コンパイル時間 | 1,780 ms |
コンパイル使用メモリ | 196,884 KB |
最終ジャッジ日時 | 2025-02-17 14:31:22 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ int T; cin >> T; for (int i = 0; i < T; i++){ int N; cin >> N; vector<int> A(N); for (int j = 0; j < N; j++){ cin >> A[j]; } vector<int> B; for (int j = 0; j < N; j++){ if (A[j] != 1){ B.push_back(A[j]); } } if (B.empty()){ cout << "No" << endl; } else if (B.size() % 2 == 1){ cout << "No" << endl; } else { int cnt = B.size(); bool ok = true; for (int j = 0; j < cnt - 1; j++){ if (B[j] == B[j + 1]){ ok = false; } } if (ok){ cout << "Yes" << endl; } else { cout << "No" << endl; } } } }