結果

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

テストケース

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

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;
    }
  }
  int m = tbl.size();
  REP(i, 0, n) {
    if (tbl.count(a[i])) {
      int idx = tbl[a[i]];
      dp[idx] += 1;
      REP(j, idx + 1, m) {
	dp[j] = max(dp[j], dp[j - 1]);
      }
    }
  }
  cout << n - dp[m - 1] << endl;
}
0