結果

問題 No.2343 (l+r)/2
ユーザー rabimea
提出日時 2025-09-30 15:11:41
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 4,386 ms
コンパイル使用メモリ 278,208 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-30 15:11:48
合計ジャッジ時間 5,362 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
#include <bits/stdc++.h>

using std::cin, std::cout, std::cerr;
using ll = long long;

int main() {
    std::ios::sync_with_stdio(false);
    int T; cin >> T;
    while(T --) {
        int n; cin >> n;
        std::vector<int> a(n);
        int x = 0, y = 0, cx = 0, cy = 0;
        for(int i = 0; i < n; i ++) {
            cin >> a[i];
            if(a[i] == 0) x ++;
            else y ++;
            if(i > 0 && a[i] == a[i - 1]) {
                if(a[i] == 0) cx ++;
                else cy ++;
            }
        }

        if(x > y) {
            std::swap(x, y);
            std::swap(cx, cy);
        }
        if(y - cy <= x || std::min(x - cx, y - cy) >= 4)
            cout << "Yes\n";
        else
            cout << "No\n";
    }
}
0