結果
| 問題 |
No.482 あなたの名は
|
| ユーザー |
ferin
|
| 提出日時 | 2017-02-11 00:17:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,091 bytes |
| コンパイル時間 | 1,405 ms |
| コンパイル使用メモリ | 161,588 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-29 08:14:26 |
| 合計ジャッジ時間 | 3,653 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 20 WA * 8 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
#define FOR(i, a, n) for (int i = (int)a; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265359
#define EPS 1e-12
vector<int> d;
int n, bit[200010];
void add(int a, int w) {
for(int x = a; x <= n; x += x & -x) bit[x] += w;
}
int sum(int a) {
int ret = 0;
for(int x = a; x > 0; x -= x & -x) ret += bit[x];
return ret;
}
int main(void)
{
int ret = 0;
ll k;
cin >> n >> k;
REP(i, n) {
int e;
cin >> e;
d.push_back(e);
if(i == e) ret++;
}
int ans = 0;
for(int i=n-1; i>=0; --i) {
ans += sum(d[i]);
add(d[i], 1);
//for(int i=1; i<=n; ++i) cout << bit[i] << " "; cout << endl;
}
ans = min(ans, ret-1);
if(ans > k) {
cout << "NO" << endl;
return 0;
}
if((k-ans)%2) cout << "NO" << endl;
else cout << "YES" << endl;
return 0;
}
ferin