結果

問題 No.482 あなたの名は
ユーザー yomo3yomo3
提出日時 2020-04-05 18:42:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 166,688 KB
実行使用メモリ 5,056 KB
最終ジャッジ日時 2023-09-16 06:48:23
合計ジャッジ時間 4,571 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 63 ms
4,636 KB
testcase_16 AC 63 ms
4,688 KB
testcase_17 AC 62 ms
4,908 KB
testcase_18 AC 62 ms
4,756 KB
testcase_19 AC 63 ms
4,644 KB
testcase_20 AC 63 ms
4,600 KB
testcase_21 AC 62 ms
4,692 KB
testcase_22 AC 63 ms
4,640 KB
testcase_23 AC 62 ms
4,688 KB
testcase_24 AC 63 ms
4,764 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

template<class T> class BIT {
private:
    vector<T> bit;
public:
    BIT(int n) : bit(vector<T>(n+1, 0)) {}
    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }
    void add(int i, int x) {
        if (i > size()) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
    int size() const { return bit.size()-1; }
};

int main()
{
    int N, K; cin >> N >> K;
    vector<int> D(N); cin >> D;
    BIT<int> bit(N);

    int c = 0;
    for (auto d : D) {
        c += bit.sum(N) - bit.sum(d-1);
        bit.add(d, 1);
    }
    bool ok = (c <= K && (c&1) == (K&1));
    cout << (ok ? "YES" : "NO") << endl;
}
0