結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-13 22:25:57 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 552 bytes |
| コンパイル時間 | 597 ms |
| コンパイル使用メモリ | 113,204 KB |
| 実行使用メモリ | 23,808 KB |
| 最終ジャッジ日時 | 2024-06-13 00:24:31 |
| 合計ジャッジ時間 | 2,165 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 6 |
ソースコード
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;
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;
}