結果

問題 No.711 競技レーティング単調増加
ユーザー しらっ亭しらっ亭
提出日時 2017-05-23 01:14:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,029 bytes
コンパイル時間 1,778 ms
コンパイル使用メモリ 171,904 KB
実行使用メモリ 814,884 KB
最終ジャッジ日時 2023-10-19 14:27:02
合計ジャッジ時間 4,401 ms
ジャッジサーバーID
(参考情報)
judge15 / 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 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
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 AC 2 ms
4,348 KB
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 AC 3 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 MLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// O(n^2) のTLE解
#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];

  const int inf = 1e9 + 1e6;
  vector<vector<int>> dp(n+1, vector<int>(n+1, inf));

  // dp[i][j] : A[i-1] までを狭義単調増加にするのに j 手かけたときの、A[i-1]の最小値。できないときは inf
  dp[0][0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i + 1; j++) {
      if (dp[i][j] >= inf) continue;
      if (dp[i][j] < A[i]) {
        // dp[i][j] に A[i] を継ぎ足す
        dp[i+1][j] = min(dp[i+1][j], A[i]);
      }
      // dp[i][j] に A[i] を操作したものを継ぎ足す
      dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + 1);
    }
  }

  for (int j = 0; j < n; j++) {
    if (dp[n][j] < inf) {
      // j 手でできていれば、それが答え
      return j;
    }
  }
  assert(false);
}

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