結果

問題 No.482 あなたの名は
ユーザー ferinferin
提出日時 2017-02-11 00:17:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,091 bytes
コンパイル時間 1,135 ms
コンパイル使用メモリ 146,620 KB
実行使用メモリ 5,088 KB
最終ジャッジ日時 2023-08-28 10:35:43
合計ジャッジ時間 3,401 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 63 ms
4,724 KB
testcase_16 AC 63 ms
5,088 KB
testcase_17 AC 63 ms
4,768 KB
testcase_18 AC 63 ms
4,792 KB
testcase_19 AC 64 ms
4,708 KB
testcase_20 AC 63 ms
4,820 KB
testcase_21 AC 63 ms
4,852 KB
testcase_22 AC 63 ms
4,880 KB
testcase_23 AC 63 ms
4,812 KB
testcase_24 AC 63 ms
4,744 KB
testcase_25 AC 63 ms
4,760 KB
testcase_26 AC 63 ms
4,660 KB
testcase_27 AC 64 ms
4,784 KB
testcase_28 AC 63 ms
4,828 KB
testcase_29 AC 60 ms
4,648 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0