結果

問題 No.2518 Adjacent Larger
ユーザー SSRSSSRS
提出日時 2023-10-27 21:26:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 204,832 KB
実行使用メモリ 5,176 KB
最終ジャッジ日時 2023-10-27 21:26:57
合計ジャッジ時間 4,390 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 35 ms
4,348 KB
testcase_02 AC 35 ms
4,348 KB
testcase_03 AC 35 ms
4,348 KB
testcase_04 AC 36 ms
4,348 KB
testcase_05 AC 37 ms
4,348 KB
testcase_06 AC 10 ms
4,348 KB
testcase_07 AC 12 ms
4,348 KB
testcase_08 AC 11 ms
4,348 KB
testcase_09 AC 12 ms
4,348 KB
testcase_10 AC 11 ms
4,348 KB
testcase_11 AC 9 ms
4,348 KB
testcase_12 AC 10 ms
4,348 KB
testcase_13 AC 10 ms
4,348 KB
testcase_14 AC 9 ms
4,348 KB
testcase_15 AC 10 ms
4,348 KB
testcase_16 AC 32 ms
5,160 KB
testcase_17 AC 20 ms
4,444 KB
testcase_18 AC 19 ms
4,452 KB
testcase_19 AC 17 ms
4,348 KB
testcase_20 AC 24 ms
4,560 KB
testcase_21 AC 33 ms
5,176 KB
testcase_22 AC 32 ms
5,176 KB
testcase_23 AC 33 ms
5,176 KB
testcase_24 AC 29 ms
4,348 KB
testcase_25 AC 30 ms
4,348 KB
testcase_26 AC 28 ms
4,348 KB
testcase_27 AC 33 ms
5,176 KB
testcase_28 AC 34 ms
5,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
      }
    }
  }
}
0