結果

問題 No.559 swapAB列
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 23:17:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 2,222 ms
コンパイル使用メモリ 74,652 KB
実行使用メモリ 41,292 KB
最終ジャッジ日時 2024-04-24 08:04:20
合計ジャッジ時間 3,377 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
41,292 KB
testcase_01 AC 93 ms
39,952 KB
testcase_02 AC 106 ms
41,096 KB
testcase_03 AC 113 ms
41,060 KB
testcase_04 AC 100 ms
40,956 KB
testcase_05 AC 102 ms
41,160 KB
testcase_06 AC 105 ms
41,060 KB
testcase_07 AC 91 ms
39,996 KB
testcase_08 AC 109 ms
40,976 KB
testcase_09 AC 103 ms
40,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String s = sc.next();
		int[] ar = new int[s.length()];
		
		int j = 0;
		int total = 0;
		for (int i=0; i<s.length(); i++) {
			if (s.charAt(i)=='A') {
				ar[j] = i-j;
				total += ar[j];
				j++;
			}
		}
		System.out.println(total);
	}
}
0