結果
問題 | No.45 回転寿司 |
ユーザー | threepipes_s |
提出日時 | 2014-11-25 01:21:17 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 238 ms / 5,000 ms |
コード長 | 2,982 bytes |
コンパイル時間 | 2,427 ms |
コンパイル使用メモリ | 80,784 KB |
実行使用メモリ | 40,896 KB |
最終ジャッジ日時 | 2024-06-08 09:24:53 |
合計ジャッジ時間 | 8,835 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 156 ms
40,820 KB |
testcase_01 | AC | 181 ms
40,552 KB |
testcase_02 | AC | 207 ms
40,660 KB |
testcase_03 | AC | 224 ms
40,812 KB |
testcase_04 | AC | 180 ms
40,796 KB |
testcase_05 | AC | 111 ms
39,080 KB |
testcase_06 | AC | 160 ms
40,596 KB |
testcase_07 | AC | 204 ms
40,596 KB |
testcase_08 | AC | 144 ms
39,536 KB |
testcase_09 | AC | 225 ms
40,896 KB |
testcase_10 | AC | 159 ms
40,604 KB |
testcase_11 | AC | 139 ms
39,232 KB |
testcase_12 | AC | 216 ms
40,752 KB |
testcase_13 | AC | 111 ms
39,436 KB |
testcase_14 | AC | 105 ms
39,508 KB |
testcase_15 | AC | 158 ms
40,480 KB |
testcase_16 | AC | 143 ms
40,496 KB |
testcase_17 | AC | 155 ms
40,628 KB |
testcase_18 | AC | 140 ms
40,624 KB |
testcase_19 | AC | 205 ms
40,840 KB |
testcase_20 | AC | 104 ms
39,432 KB |
testcase_21 | AC | 112 ms
39,280 KB |
testcase_22 | AC | 81 ms
38,968 KB |
testcase_23 | AC | 83 ms
39,196 KB |
testcase_24 | AC | 89 ms
38,840 KB |
testcase_25 | AC | 72 ms
39,136 KB |
testcase_26 | AC | 171 ms
40,608 KB |
testcase_27 | AC | 193 ms
40,484 KB |
testcase_28 | AC | 163 ms
40,736 KB |
testcase_29 | AC | 187 ms
40,736 KB |
testcase_30 | AC | 190 ms
40,760 KB |
testcase_31 | AC | 79 ms
39,368 KB |
testcase_32 | AC | 82 ms
39,052 KB |
testcase_33 | AC | 238 ms
40,664 KB |
ソースコード
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.BitSet; import java.util.Comparator; import java.util.List; import java.util.TreeSet; public class Main { public static int w; public static int k; public static int n; // public static int[][] dp; public static int[] a; public static int[] b; public static List<double[]> list = new ArrayList<double[]>(); public static TreeSet<Integer> set = new TreeSet<Integer>(); // public static PriorityQueue<Integer> pq = new PriorityQueue<Integer>(); public static void main(String[] args) throws NumberFormatException, IOException{ ContestScanner in = new ContestScanner(); n = in.nextInt(); int[] sushi = new int[n]; long[] dp = new long[1000*100+1]; for(int i=0; i<n; i++){ sushi[i] = in.nextInt(); } dp[sushi[0]] = 1; for(int i=1; i<n; i++){ if(dp[sushi[i]] == 0) dp[sushi[i]] = i+1; int max = 100000 - sushi[i]; for(int j=max; j>=0; j--){ if(dp[j] > 0 && dp[j + sushi[i]] == 0 && dp[j] < i){ dp[j + sushi[i]] = i+1; } } } for(int i=0; i<=10; i++){ System.err.print(dp[i]+" "); } int count = 100000; while(dp[count--] == 0); System.out.println(count+1); } } 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 MyMath{ public static long fact(long n){ long res = 1; while(n > 0){ res *= n--; } return res; } public static long[][] pascalT(int n){ long[][] tri = new long[n][]; for(int i=0; i<n; i++){ tri[i] = new long[i+1]; for(int j=0; j<i+1; j++){ if(j == 0 || j == i){ tri[i][j] = 1; }else{ tri[i][j] = tri[i-1][j-1] + tri[i-1][j]; } } } return tri; } } class MyComp implements Comparator<Integer>{ public int compare(Integer arg0, Integer arg1) { return arg0 - arg1; } } // //class MyCompB implements Comparator<int[]>{ // public int compare(int[] arg0, int[] arg1) { // return arg0[1] - arg1[1]; // } //} class ContestScanner{ private BufferedReader reader; private String[] line; private int idx; public ContestScanner() throws FileNotFoundException{ reader = new BufferedReader(new InputStreamReader(System.in)); } 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()); } }