結果

問題 No.482 あなたの名は
ユーザー hotpepsihotpepsi
提出日時 2017-06-10 18:38:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 60,824 KB
実行使用メモリ 8,736 KB
最終ジャッジ日時 2023-10-24 20:34:12
合計ジャッジ時間 6,415 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

class BIT {
	std::vector<int> bit;
	int size;
public:
	BIT() { }
	BIT(int sz) { init(sz); }
	void init(int sz) {
		bit = std::vector<int>((size = sz) + 1);
	}
	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
	void add(int i, int x) {
		while (i <= size) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

int main(int argc, char *argv[]) {
	int n, k, c = 0;
	cin >> n >> k;
	BIT b(200001);
	for (int i = 0; i < n; ++i) {
		int d;
		cin >> d;
		c += i - b.sum(d);
		b.add(d, 1);
	}
	bool ans = c <= k && ((k - c) % 2) == 0;
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}
0