結果
| 問題 | No.5 数字のブロック |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-21 21:21:42 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 163 ms / 5,000 ms |
| コード長 | 471 bytes |
| 記録 | |
| コンパイル時間 | 2,534 ms |
| コンパイル使用メモリ | 82,188 KB |
| 実行使用メモリ | 51,624 KB |
| 最終ジャッジ日時 | 2026-05-12 15:47:47 |
| 合計ジャッジ時間 | 6,563 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int L=sc.nextInt();
int n=sc.nextInt();
int w[]=new int[n];
for(int i=0;i<n;i++){
w[i]=sc.nextInt();
}
Arrays.sort(w);
int ans=0;
int sum=0;
int i=0;
while(i<n){
if(L-sum>=w[i]){
sum+=w[i];
ans++;
if(sum>=L)break;
}
i++;
}
System.out.println(ans);
}}