結果

問題 No.672 最長AB列
ユーザー AreTrashAreTrash
提出日時 2018-05-04 17:51:02
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 603 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 100,144 KB
実行使用メモリ 31,040 KB
最終ジャッジ日時 2023-09-10 09:45:33
合計ジャッジ時間 4,368 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
20,520 KB
testcase_01 AC 53 ms
20,520 KB
testcase_02 AC 52 ms
20,524 KB
testcase_03 AC 52 ms
20,600 KB
testcase_04 WA -
testcase_05 AC 52 ms
20,516 KB
testcase_06 AC 53 ms
20,460 KB
testcase_07 AC 53 ms
20,452 KB
testcase_08 AC 53 ms
20,588 KB
testcase_09 AC 73 ms
31,040 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 60 ms
20,676 KB
testcase_14 WA -
testcase_15 AC 60 ms
20,928 KB
testcase_16 AC 61 ms
22,696 KB
testcase_17 AC 67 ms
25,772 KB
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;

namespace No672
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var dic = new Dictionary<int, int>();

            var count = 0;
            var ans = 0;
            for (var i = 0; i < S.Length; i++)
            {
                count += (S[i] - 'A') * 2 - 1;
                if (dic.TryGetValue(count, out var dist)) ans = Math.Max(ans, i - dist);
                else dic.Add(count, i);
            }

            Console.WriteLine(ans);
        }
    }
}
0