結果

問題 No.9008 空白区切りで与えられる数値データの合計値を求める(テスト用)
ユーザー ShotaroSuzu
提出日時 2020-05-19 17:48:38
言語 Java
(openjdk 23)
結果
AC  
実行時間 859 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 76,656 KB
実行使用メモリ 64,268 KB
最終ジャッジ日時 2024-10-01 22:54:00
合計ジャッジ時間 10,986 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder.tutorial.sum.bywhitespace;

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

public class Main {

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

	}

	private void execute() {
		List<Long> nums = read();

		long sum = 0L;

		for (Long num : nums) {
			sum += num;
		}

		System.out.println(sum);
	}

	private List<Long> read() {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		int length = sc.nextInt();

		List<Long> numsList = new ArrayList<>();
		for (int i = 0; i < length; i++) {
			numsList.add(sc.nextLong());
		}
		return numsList;
	}

}
0