結果

問題 No.617 Nafmo、買い出しに行く
ユーザー Pump0129Pump0129
提出日時 2018-03-26 18:37:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 740 bytes
コンパイル時間 3,129 ms
コンパイル使用メモリ 74,148 KB
実行使用メモリ 56,056 KB
最終ジャッジ日時 2023-09-07 12:46:37
合計ジャッジ時間 5,994 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 125 ms
55,656 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 124 ms
55,764 KB
testcase_06 AC 126 ms
55,724 KB
testcase_07 AC 125 ms
55,720 KB
testcase_08 AC 125 ms
56,056 KB
testcase_09 AC 125 ms
55,640 KB
testcase_10 AC 125 ms
55,616 KB
testcase_11 AC 127 ms
55,744 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 125 ms
55,612 KB
testcase_16 AC 127 ms
55,812 KB
testcase_17 AC 127 ms
55,804 KB
testcase_18 AC 126 ms
55,992 KB
testcase_19 AC 124 ms
55,952 KB
testcase_20 AC 125 ms
55,764 KB
testcase_21 AC 126 ms
55,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package net.ipipip0129.yukicoder.no617;

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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String line = scan.nextLine();
		int count = Integer.parseInt(line.split(" ")[0]);
		int maxweight = Integer.parseInt(line.split(" ")[1]);
		
		List<Integer> stocks = new ArrayList<Integer>();
		
		for (int i = 0; i < count; i++) {
			stocks.add(Integer.parseInt(scan.nextLine()));
		}
		
		scan.close();
		
		int cw = 0;
		
		for (int i = stocks.size() - 1; 0 <= i; i--) {
			if (cw + stocks.get(i) <= maxweight) {
				cw += stocks.get(i);
			}
		}
		
		System.out.println(cw);
	}
}
0