結果

問題 No.482 あなたの名は
ユーザー kekenxkekenx
提出日時 2020-02-02 16:30:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 2,291 ms
コンパイル使用メモリ 169,356 KB
実行使用メモリ 5,708 KB
最終ジャッジ日時 2023-10-19 01:16:49
合計ジャッジ時間 5,977 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll get_cnt(vector<int> &a) {
  int n = a.size();
  if (n <= 1) return 0;

  ll cnt = 0;
  vector<int> b(a.begin(), a.begin() + n / 2);
  vector<int> c(a.begin() + n / 2, a.end());

  cnt += get_cnt(b);
  cnt += get_cnt(c);

  int ai = 0, bi = 0, ci = 0;
  while (ai < n) {
    if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
      a[ai++] = b[bi++];
    } else {
      cnt += n / 2 - bi;
      a[ai++] = c[ci++];
    }
  }
  return cnt;
}

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> d(n);
  for (int i = 0; i < n; ++i) cin >> d[i];

  ll cnt = get_cnt(d);
  if (cnt <= k) {
    puts("YES");
  } else {
    puts("NO");
  }
  return 0;
}
0