結果
| 問題 | No.672 最長AB列 |
| コンテスト | |
| ユーザー |
uw_yu1rabbit
|
| 提出日時 | 2020-11-27 21:35:17 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 669 bytes |
| 記録 | |
| コンパイル時間 | 3,455 ms |
| コンパイル使用メモリ | 104,576 KB |
| 実行使用メモリ | 28,160 KB |
| 最終ジャッジ日時 | 2026-04-03 16:45:38 |
| 合計ジャッジ時間 | 2,216 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
String s = Console.ReadLine();
Int32 n = s.Length;
var mp = new Dictionary<Int32,Int32>();
Int32 p = 0;
mp[0] = -1;
Int32 ans = 0;
for (Int32 i = 0; i < n; i++)
{
if (s[i] == 'A') p++;
else p--;
if (mp.ContainsKey(p)) ans = Math.Max(ans, i - mp[p]);
else mp[p] = i;
}
Console.WriteLine(ans);
}
}
}
uw_yu1rabbit