結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
|
| 提出日時 | 2016-02-17 20:13:45 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 92 ms / 5,000 ms |
| コード長 | 1,161 bytes |
| コンパイル時間 | 2,696 ms |
| コンパイル使用メモリ | 74,968 KB |
| 実行使用メモリ | 53,304 KB |
| 最終ジャッジ日時 | 2024-11-18 08:15:44 |
| 合計ジャッジ時間 | 5,712 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.
*/
package yukicoder001_100;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
/**
*
* @author yuya
*/
public class No005 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String line1 = br.readLine();
String line2 = br.readLine();
String line3 = br.readLine();
int L = Integer.parseInt(line1);
int N = Integer.parseInt(line2);
String [] s = line3.split(" ",0);
int n[] = new int[N];
for(int i=0;i<s.length;i++){
n[i]=Integer.parseInt(s[i]);
}
Arrays.sort(n);
int ans=0;
int b =0;
for(int i=0;i<=n.length-1;i++){
b+=n[i];
if(b<=L){
ans++;
}else{
break;
}
}
System.out.println(ans);
}
}