結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
history_Bass
|
| 提出日時 | 2017-02-28 22:50:01 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 188 ms / 5,000 ms |
| コード長 | 855 bytes |
| コンパイル時間 | 3,582 ms |
| コンパイル使用メモリ | 77,652 KB |
| 実行使用メモリ | 44,152 KB |
| 最終ジャッジ日時 | 2024-11-18 10:54:50 |
| 合計ジャッジ時間 | 9,363 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.util.Scanner;
import java.util.Arrays;
public class block {
protected static String wide[];
protected static int[] wideN;
public static void main(String args[]){
//文字の読み込み
Scanner sc=new Scanner(System.in);
String[] line=new String[3];
line[0]=sc.nextLine();
line[1]=sc.nextLine();
line[2]=sc.nextLine();
//文字を数値に変換
int[] n=new int[3];
n[0]=Integer.parseInt(line[0]);
n[1]=Integer.parseInt(line[1]);
wide=line[2].split(" ",0);
wideN=new int[wide.length];
int m=0;
while(m<wide.length){
wideN[m]=Integer.parseInt(wide[m]);
m++;
}
Arrays.sort(wideN);//配列を昇順に並べる
int count=0,rent=n[0];
for(int i=0;i<n[1];i++){
if(rent-wideN[i]>=0){
rent=rent-wideN[i];
count++;
}else{
break;
}
}
System.out.println(count);
}
}
history_Bass