結果

問題 No.559 swapAB列
ユーザー packer_jppacker_jp
提出日時 2017-09-13 19:55:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 2,329 ms
コンパイル使用メモリ 76,436 KB
実行使用メモリ 41,440 KB
最終ジャッジ日時 2024-04-25 09:28:31
合計ジャッジ時間 4,348 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,116 KB
testcase_01 AC 130 ms
41,188 KB
testcase_02 AC 130 ms
41,396 KB
testcase_03 AC 131 ms
41,336 KB
testcase_04 AC 136 ms
41,440 KB
testcase_05 AC 130 ms
41,052 KB
testcase_06 AC 118 ms
39,856 KB
testcase_07 AC 127 ms
40,740 KB
testcase_08 AC 130 ms
41,008 KB
testcase_09 AC 129 ms
40,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        List<Character> SList = new ArrayList<>();
        for (int i = 0; i < S.length(); i++) {
            SList.add(S.charAt(i));
        }
        int ans = 0;
        while (SList.contains('A')) {
            ans += SList.indexOf('A');
            SList.remove(new Character('A'));
        }
        System.out.println(ans);
    }
}
0