結果
| 問題 | No.711 競技レーティング単調増加 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-10 14:22:12 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 117 ms / 2,000 ms |
| コード長 | 965 bytes |
| 記録 | |
| コンパイル時間 | 983 ms |
| コンパイル使用メモリ | 127,364 KB |
| 実行使用メモリ | 32,788 KB |
| 最終ジャッジ日時 | 2024-06-13 01:25:02 |
| 合計ジャッジ時間 | 4,312 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;
immutable int INF = 1 << 29;
void main() {
auto N = readln.chomp.to!int;
auto A = readln.split.map!(to!long).array;
long[] B;
int ans = 0;
foreach (i; 0..N) {
if (A[i] - i > 0) {
B ~= A[i] - i;
} else {
ans += 1;
}
}
N = B.length.to!int;
auto C = B.dup;
C = C.sort().uniq().array;
int[long] comp;
foreach (i; 0..C.length.to!int) comp[C[i]] = i;
auto dp = new int[](N+1);
fill(dp, INF);
dp[0] = -1;
foreach (i; 0..N) {
int b = comp[B[i]];
int lb = dp.assumeSorted.lowerBound(b+1).length.to!int;
dp[lb] = b;
}
int tmp = 0;
foreach (i; 0..N+1) if (dp[i] < INF) tmp = N - i;
ans += tmp;
ans.writeln;
}