結果

問題 No.482 あなたの名は
ユーザー k-matsk-mats
提出日時 2017-02-11 00:06:13
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 793 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 52,504 KB
実行使用メモリ 7,692 KB
最終ジャッジ日時 2023-08-28 10:24:52
合計ジャッジ時間 22,178 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,692 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1,711 ms
4,376 KB
testcase_16 AC 1,728 ms
4,376 KB
testcase_17 AC 1,721 ms
4,380 KB
testcase_18 AC 1,715 ms
4,432 KB
testcase_19 AC 1,731 ms
4,380 KB
testcase_20 AC 1,717 ms
4,376 KB
testcase_21 AC 1,718 ms
4,376 KB
testcase_22 AC 1,734 ms
4,380 KB
testcase_23 AC 1,717 ms
4,376 KB
testcase_24 AC 1,725 ms
4,380 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;

    int d[n];
    for (int i = 0; i < n; i++) {
        cin >> d[i];
    }

    int cnt = 0;

    for (int i = 0; i < n - 1; i++) {
        if (d[i] == i + 1) {
            continue;
        }

        for (int j = i + 1; j < n; j++) {
            if (d[j] == i + 1) {
                int tmp = d[i];
                d[i] = d[j];
                d[j] = tmp;
                cnt++;
                break;
            }
        }

        if (cnt > k) {
            cout << "NO" << endl;
            return;
        }
    }

    if ((k - cnt) % 2 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


int main(int argc, char *argv[]) {
    solve();

    return 0;
}
0