結果

問題 No.2424 Josouzai
ユーザー 松本昇一松本昇一
提出日時 2023-08-20 11:06:29
言語 JavaScript
(node v21.7.1)
結果
WA  
実行時間 -
コード長 1,228 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 5,504 KB
実行使用メモリ 54,860 KB
最終ジャッジ日時 2024-05-07 18:00:17
合計ジャッジ時間 7,060 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
44,416 KB
testcase_01 AC 59 ms
38,912 KB
testcase_02 AC 58 ms
38,912 KB
testcase_03 WA -
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
    // inputにはすべての入力の文字列が与えられるので必要に応じて input.split("\n") などで分割する。

    var data = input.split("\n")
    
    var first_line = data[0].split(" ")
    var second_line = data[1].split(" ")
    
    let nums = []
    for(let i=0;i<first_line.length;i++){
    	nums.push(parseInt(first_line[i]))
    }
    
    let data_list = []
    for(let i=0;i<second_line.length;i++){
    	data_list.push(parseInt(second_line[i]))
    }
    
    
    let total_value = 0
    for(i=0; i<data_list.length; i++){
    	total_value += data_list[i]
    }
    
    while(total_value > nums[1]){
    	let max_val = Math.max.apply(null, data_list)
    	let idx = data_list.indexOf(max_val)
    	data_list.splice(idx,1)
    	
    	total_value = 0
	    for(i=0; i<data_list.length; i++){
	    	total_value += data_list[i]
	    }
	    
	    // console.log(total_value)
	    if(total_value <= nums[1]){
	    	console.log(data_list.length ,nums[1] - total_value)
	    	
	    }
	    
    }
    	
    

	
	// console.log(total_value)
 //   console.log(nums)
 //   console.log(data_list)
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0