結果

問題 No.711 競技レーティング単調増加
ユーザー koba-e964koba-e964
提出日時 2017-10-01 19:22:27
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,252 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 111,700 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-04-27 17:32:43
合計ジャッジ時間 5,838 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 TLE -
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 #

#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;



int main(void) {
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) {
    cin >> a[i];
    a[i] -= i + 1;
  }
  // Coord compression
  map<ll, int> tbl;
  vector<ll> inv_tbl;
  {
    set<int> vals;
    vals.insert(0);
    REP(i, 0, n) {
      if (a[i] >= 0) {
      vals.insert(a[i]);
      }
    }
    inv_tbl = vector<ll>(vals.begin(), vals.end());
    sort(inv_tbl.begin(), inv_tbl.end());
    REP(i, 0, inv_tbl.size()) {
      tbl[inv_tbl[i]] = i;
    }
  }
  VL dp(200010);
  int m = tbl.size();
  REP(i, 0, n) {
    if (tbl.count(a[i])) {
      int idx = tbl[a[i]];
      REP(j, idx, m) {
	dp[j] = max(dp[j], j >= 1 ? dp[j - 1] : 0) + (j == idx ? 1 : 0);
      }
    }
  }
  cout << n - dp[m - 1] << endl;
}
0