結果
問題 | No.672 最長AB列 |
ユーザー | nebukuro09 |
提出日時 | 2018-04-13 22:27:47 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 93 ms / 2,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 601 ms |
コンパイル使用メモリ | 109,576 KB |
実行使用メモリ | 26,600 KB |
最終ジャッジ日時 | 2024-06-13 00:24:35 |
合計ジャッジ時間 | 1,688 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
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; void main() { auto S = readln.chomp; int[][int] A; int tmp = 0; A[0] ~= -1; foreach (i; 0..S.length) { if (S[i] == 'A') tmp += 1; else tmp -= 1; A[tmp] ~= i.to!int; } int ans = 0; foreach (k; A.keys) { if (A[k].length < 2) continue; ans = max(ans, A[k].back - A[k].front); } ans.writeln; }