結果
| 問題 | No.482 あなたの名は |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-05 19:23:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 966 bytes |
| 記録 | |
| コンパイル時間 | 1,564 ms |
| コンパイル使用メモリ | 169,784 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-03 22:49:00 |
| 合計ジャッジ時間 | 3,871 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 WA * 3 |
ソースコード
#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()
{
cin.tie(0);ios::sync_with_stdio(false);
ll 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;
}