結果

問題 No.559 swapAB列
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 23:17:26
言語 Java
(openjdk 23)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 3,018 ms
コンパイル使用メモリ 74,460 KB
実行使用メモリ 54,112 KB
最終ジャッジ日時 2024-11-06 15:25:05
合計ジャッジ時間 4,600 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

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