結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
SagToki
|
| 提出日時 | 2018-05-02 13:56:09 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 278 ms / 5,000 ms |
| コード長 | 955 bytes |
| コンパイル時間 | 3,840 ms |
| コンパイル使用メモリ | 74,796 KB |
| 実行使用メモリ | 59,004 KB |
| 最終ジャッジ日時 | 2024-11-18 12:22:28 |
| 合計ジャッジ時間 | 11,988 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
/**
*
* @author tokio
*/
public class suuzi {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int L = scanner.nextInt();
int N = scanner.nextInt();
int[] W = new int[N];
int sum = 0;
int count = 0;
for(int i=0 ; i<N ; i++){
W[i] = scanner.nextInt();
}
Arrays.sort(W);
//while(L >= sum){
// sum += W[i];
// i++;
// }
for(int i = 0 ; i < N ; i++){
if(L >= sum + W[i]){
sum += W[i];
count++;
}else{
break;
}
}
System.out.println(count);
}
}
SagToki