結果
問題 |
No.8009 異なる数字の最大の範囲(勉強会用)
|
ユーザー |
|
提出日時 | 2018-02-02 08:11:01 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,057 bytes |
コンパイル時間 | 651 ms |
コンパイル使用メモリ | 102,772 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 23:46:53 |
合計ジャッジ時間 | 1,520 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 WA * 15 |
ソースコード
import std.stdio, std.string, std.conv; import std.range, std.algorithm, std.array; void main() { int n; int[] a; scan(n); a = readln.split.to!(int[]); auto b = new bool[](a.reduce!max + 1); int ans; for (int l,r; r < n; r++) { if (b[a[r]]) { for (; b[a[r]]; l++) { b[a[l]] = 0; } } debug { writefln("(l, r) = (%s, %s)", l, r); } ans = r - l + 1; b[a[r]] = 1; } writeln(ans); } void scan(T...)(ref T args) { import std.stdio : readln; import std.algorithm : splitter; import std.conv : to; import std.range.primitives; auto line = readln().splitter(); foreach (ref arg; args) { arg = line.front.to!(typeof(arg)); line.popFront(); } assert(line.empty); } void fillAll(R, T)(ref R arr, T value) { static if (is(typeof(arr[] = value))) { arr[] = value; } else { foreach (ref e; arr) { fillAll(e, value); } } }