結果

問題 No.711 競技レーティング単調増加
ユーザー しらっ亭しらっ亭
提出日時 2017-05-23 00:49:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 785 bytes
コンパイル時間 1,927 ms
コンパイル使用メモリ 173,732 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-19 14:24:22
合計ジャッジ時間 13,023 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 16 ms
4,348 KB
testcase_37 AC 455 ms
4,348 KB
testcase_38 AC 423 ms
4,348 KB
testcase_39 AC 239 ms
4,348 KB
testcase_40 WA -
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 201 ms
4,348 KB
testcase_43 AC 272 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// O(n^2) のTLE解を X 個だけ持って、O(NX) にした WA 解
#include <bits/stdc++.h>
using namespace std;

int solve() {
  int n;
  cin >> n;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];

  vector<pair<int, int>> q1, q2;
  auto &cur = q1;
  auto &nex = q2;

  cur.emplace_back(0, 0);
  const int X = 1000;

  for (int i = 0; i < n; i++) {
    for (auto cl : cur) {
      if (nex.size() > X) break;
      int c = cl.first;
      int l = cl.second;

      if (l < A[i]) {
        nex.emplace_back(c, A[i]);
      }
      nex.emplace_back(c + 1, l + 1);
    }
    swap(cur, nex);
    nex.clear();
  }

  return min_element(cur.begin(), cur.end())->first;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  cout << solve() << endl;
  return 0;
}
0