結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2018-04-16 11:53:28 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 500 bytes |
コンパイル時間 | 613 ms |
コンパイル使用メモリ | 101,128 KB |
実行使用メモリ | 18,928 KB |
最終ジャッジ日時 | 2024-06-13 00:27:53 |
合計ジャッジ時間 | 1,627 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
Main.d(11): Deprecation: foreach: loop index implicitly converted from `size_t` to `int` Main.d(18): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
ソースコード
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}} void main() { string s; readV(s); int[int] h; auto a = 0; foreach (int i, c; s) { a += c == 'A' ? +1 : -1; h[a] = i; } a = 0; auto l = 0; foreach (int i, c; s) { if (a in h && h[a] > i) l = max(l, h[a]-i+1); a += c == 'A' ? +1 : -1; } writeln(l); }