結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
koukonko
|
| 提出日時 | 2015-12-07 11:01:39 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 232 ms / 5,000 ms |
| コード長 | 868 bytes |
| コンパイル時間 | 2,246 ms |
| コンパイル使用メモリ | 77,656 KB |
| 実行使用メモリ | 51,956 KB |
| 最終ジャッジ日時 | 2024-11-18 07:58:12 |
| 合計ジャッジ時間 | 6,900 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) {
BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));
try {
int L = Integer.parseInt(buff.readLine());
int N = Integer.parseInt(buff.readLine());
int[] box = new int[N];
String[] str = buff.readLine().split(" ");
for (int i = 0; i < N; ++i) {
box[i] = Integer.parseInt(str[i]);
for (int j = 0; j < i; ++j) {
if (box[i] < box[j]) {
int w = box[i];
box[i] = box[j];
box[j] = w;
}
}
}
int ans = 0;
int sum = 0;
for (int i = 0; i < N; ++i) {
sum += box[i];
if (sum > L) {
break;
}
++ans;
}
System.out.println(ans);
} catch (NumberFormatException e) {
} catch (IOException e) {
}
}
}
koukonko