結果

問題 No.9011 数字を全て足そう(数字だけ)
ユーザー パカかすみパカかすみ
提出日時 2022-12-05 10:46:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 4,147 ms
コンパイル使用メモリ 85,192 KB
実行使用メモリ 54,656 KB
最終ジャッジ日時 2024-04-20 13:20:05
合計ジャッジ時間 8,776 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
54,184 KB
testcase_01 AC 141 ms
54,272 KB
testcase_02 AC 144 ms
54,272 KB
testcase_03 AC 143 ms
54,136 KB
testcase_04 AC 145 ms
54,040 KB
testcase_05 AC 144 ms
54,264 KB
testcase_06 AC 149 ms
53,888 KB
testcase_07 AC 150 ms
54,292 KB
testcase_08 AC 149 ms
54,128 KB
testcase_09 AC 148 ms
54,656 KB
testcase_10 AC 147 ms
54,252 KB
testcase_11 AC 145 ms
54,232 KB
testcase_12 AC 148 ms
54,432 KB
testcase_13 AC 144 ms
54,576 KB
testcase_14 AC 151 ms
54,260 KB
testcase_15 AC 144 ms
54,096 KB
testcase_16 AC 146 ms
54,556 KB
testcase_17 AC 143 ms
54,236 KB
testcase_18 AC 146 ms
54,148 KB
testcase_19 AC 147 ms
54,320 KB
testcase_20 AC 149 ms
54,472 KB
testcase_21 AC 147 ms
54,272 KB
testcase_22 AC 145 ms
54,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class App {
    public static void main(String[] args) throws Exception {
        // System.out.println("Hello, World!");
        // ■標準入力
        // Scannerクラス
        Scanner scanner = new Scanner(System.in);

        // nextLineメソッド
        String s = scanner.nextLine();

        String[] sArray = s.split("");
        List<String> sList = Arrays.asList(sArray);
        List<Integer> sIntList = new ArrayList<>();
        sList.stream().forEach(h -> {
            Integer intS = Integer.valueOf(h);
            sIntList.add(intS);
        });

        int total = sIntList.stream().mapToInt(val -> val).sum();

        System.out.println(total);
        scanner.close();
    }
}
0