結果

問題 No.559 swapAB列
ユーザー matsuyoshi30matsuyoshi30
提出日時 2018-09-28 23:48:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 452 bytes
コンパイル時間 3,453 ms
コンパイル使用メモリ 73,964 KB
実行使用メモリ 41,564 KB
最終ジャッジ日時 2024-04-20 12:10:58
合計ジャッジ時間 5,657 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
41,396 KB
testcase_01 AC 125 ms
41,064 KB
testcase_02 AC 114 ms
39,884 KB
testcase_03 AC 127 ms
41,432 KB
testcase_04 AC 127 ms
41,564 KB
testcase_05 AC 132 ms
41,280 KB
testcase_06 AC 130 ms
41,336 KB
testcase_07 AC 126 ms
41,208 KB
testcase_08 AC 130 ms
41,272 KB
testcase_09 AC 130 ms
41,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();

        int[] arr = new int[s.length()];
        int ans = 0, j = 0;
        for(int i=0; i<s.length(); i++) {
            if(s.charAt(i) == 'A') {
                arr[j] = i - j;
                ans += arr[j];
                j++;
            }
        }

        System.out.println(ans);
    }
}
0