結果
問題 | No.5 数字のブロック |
ユーザー | threepipes_s |
提出日時 | 2015-02-16 23:32:18 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 105 ms / 5,000 ms |
コード長 | 2,046 bytes |
コンパイル時間 | 2,218 ms |
コンパイル使用メモリ | 78,732 KB |
実行使用メモリ | 40,440 KB |
最終ジャッジ日時 | 2024-04-29 00:43:26 |
合計ジャッジ時間 | 5,643 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
36,672 KB |
testcase_01 | AC | 52 ms
36,684 KB |
testcase_02 | AC | 53 ms
36,952 KB |
testcase_03 | AC | 83 ms
38,524 KB |
testcase_04 | AC | 77 ms
38,496 KB |
testcase_05 | AC | 93 ms
39,712 KB |
testcase_06 | AC | 78 ms
38,668 KB |
testcase_07 | AC | 86 ms
38,148 KB |
testcase_08 | AC | 92 ms
39,888 KB |
testcase_09 | AC | 62 ms
37,440 KB |
testcase_10 | AC | 95 ms
39,884 KB |
testcase_11 | AC | 85 ms
37,936 KB |
testcase_12 | AC | 102 ms
39,700 KB |
testcase_13 | AC | 102 ms
39,400 KB |
testcase_14 | AC | 54 ms
36,796 KB |
testcase_15 | AC | 55 ms
37,052 KB |
testcase_16 | AC | 105 ms
39,716 KB |
testcase_17 | AC | 96 ms
39,628 KB |
testcase_18 | AC | 104 ms
39,968 KB |
testcase_19 | AC | 102 ms
40,440 KB |
testcase_20 | AC | 54 ms
37,140 KB |
testcase_21 | AC | 55 ms
36,984 KB |
testcase_22 | AC | 53 ms
37,076 KB |
testcase_23 | AC | 54 ms
36,960 KB |
testcase_24 | AC | 53 ms
36,692 KB |
testcase_25 | AC | 55 ms
36,956 KB |
testcase_26 | AC | 51 ms
36,848 KB |
testcase_27 | AC | 52 ms
37,092 KB |
testcase_28 | AC | 52 ms
36,692 KB |
testcase_29 | AC | 84 ms
38,256 KB |
testcase_30 | AC | 64 ms
37,412 KB |
testcase_31 | AC | 52 ms
36,848 KB |
testcase_32 | AC | 52 ms
36,848 KB |
testcase_33 | AC | 54 ms
36,848 KB |
ソースコード
import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.TreeSet; public class Main { public static boolean result[]; public static int dp[][]; public static void main(String[] args) throws NumberFormatException, IOException{ ContestScanner in = new ContestScanner(); int l = in.nextInt(); int n = in.nextInt(); int[] w = new int[n]; for(int i=0; i<n; i++){ w[i] = in.nextInt(); } int count = 0; Arrays.sort(w); for(int i=0; i<n; i++){ l -= w[i]; if(l<0) break; count++; } System.out.println(count); } } class MyComp implements Comparator<int[]>{ public int compare(int[] a, int[] b) { return a[0] - b[0]; } } class Reverse implements Comparator<Integer>{ public int compare(Integer arg0, Integer arg1) { return arg1 - arg0; } } class Node{ int id; List<Node> edge = new ArrayList<Node>(); public Node(int id){ this.id = id; } public void createEdge(Node node){ edge.add(node); } } class ContestScanner{ private BufferedReader reader; private String[] line; private int idx; public ContestScanner() throws FileNotFoundException{ reader = new BufferedReader(new InputStreamReader(System.in)); } public ContestScanner(String filename) throws FileNotFoundException{ reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename))); } public String nextToken() throws IOException{ if(line == null || line.length <= idx){ line = reader.readLine().trim().split(" "); idx = 0; } return line[idx++]; } public long nextLong() throws IOException, NumberFormatException{ return Long.parseLong(nextToken()); } public int nextInt() throws NumberFormatException, IOException{ return (int)nextLong(); } public double nextDouble() throws NumberFormatException, IOException{ return Double.parseDouble(nextToken()); } }