結果
| 問題 |
No.711 競技レーティング単調増加
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-10 14:26:48 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 2,000 ms |
| コード長 | 813 bytes |
| コンパイル時間 | 849 ms |
| コンパイル使用メモリ | 119,780 KB |
| 実行使用メモリ | 13,160 KB |
| 最終ジャッジ日時 | 2024-06-13 01:25:13 |
| 合計ジャッジ時間 | 3,272 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 long INF = 1L << 60;
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 dp = new long[](N+1);
fill(dp, INF);
dp[0] = -1;
foreach (i; 0..N) {
int lb = dp.assumeSorted.lowerBound(B[i]+1).length.to!int;
dp[lb] = B[i];
}
int tmp = 0;
foreach (i; 0..N+1) if (dp[i] < INF) tmp = N - i;
ans += tmp;
ans.writeln;
}