結果

問題 No.3750 Mischievous Resident (Easy)
コンテスト
ユーザー marc2825
提出日時 2026-08-06 10:05:54
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 813 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,116 ms
コンパイル使用メモリ 221,116 KB
実行使用メモリ 9,944 KB
最終ジャッジ日時 2026-10-02 20:50:55
合計ジャッジ時間 4,213 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 19 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int Q;
    cin >> Q;

    while (Q--) {
        int N, M;
        cin >> N >> M;

        vector<int> S(M), G(M);
        for (int& x : S) cin >> x;
        for (int& x : G) cin >> x;

        sort(S.begin(), S.end());
        sort(G.begin(), G.end());

        vector<pair<int, int>> A(M);
        for (int i = 0; i < M; ++i) {
            A[i] = {S[i], G[i]};
        }

        bool ok = true;
        for (int i = 1; i < M; ++i) {
            auto [s1, g1] = A[i - 1];
            auto [s2, g2] = A[i];

            if (g1 > g2 ||
                (g1 == g2 && !(s1 == s2 && s1 == g1))) {
                ok = false;
            }
        }

        cout << (ok ? "Yes\n" : "No\n");
    }
}
0