結果
問題 | No.45 回転寿司 |
ユーザー | threepipes_s |
提出日時 | 2014-11-25 01:21:17 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 286 ms / 5,000 ms |
コード長 | 2,982 bytes |
コンパイル時間 | 2,856 ms |
コンパイル使用メモリ | 89,276 KB |
実行使用メモリ | 54,040 KB |
最終ジャッジ日時 | 2023-08-27 13:50:07 |
合計ジャッジ時間 | 8,729 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 143 ms
53,464 KB |
testcase_01 | AC | 170 ms
53,564 KB |
testcase_02 | AC | 197 ms
53,628 KB |
testcase_03 | AC | 259 ms
53,880 KB |
testcase_04 | AC | 175 ms
53,480 KB |
testcase_05 | AC | 107 ms
52,524 KB |
testcase_06 | AC | 164 ms
53,592 KB |
testcase_07 | AC | 199 ms
54,040 KB |
testcase_08 | AC | 131 ms
52,492 KB |
testcase_09 | AC | 204 ms
53,304 KB |
testcase_10 | AC | 150 ms
53,604 KB |
testcase_11 | AC | 126 ms
52,864 KB |
testcase_12 | AC | 255 ms
53,640 KB |
testcase_13 | AC | 106 ms
52,456 KB |
testcase_14 | AC | 100 ms
52,216 KB |
testcase_15 | AC | 156 ms
53,552 KB |
testcase_16 | AC | 134 ms
53,356 KB |
testcase_17 | AC | 145 ms
53,712 KB |
testcase_18 | AC | 129 ms
51,804 KB |
testcase_19 | AC | 183 ms
53,676 KB |
testcase_20 | AC | 96 ms
52,464 KB |
testcase_21 | AC | 102 ms
52,296 KB |
testcase_22 | AC | 79 ms
52,148 KB |
testcase_23 | AC | 81 ms
52,124 KB |
testcase_24 | AC | 80 ms
52,020 KB |
testcase_25 | AC | 79 ms
51,500 KB |
testcase_26 | AC | 151 ms
53,628 KB |
testcase_27 | AC | 183 ms
53,544 KB |
testcase_28 | AC | 158 ms
53,668 KB |
testcase_29 | AC | 176 ms
53,652 KB |
testcase_30 | AC | 177 ms
53,488 KB |
testcase_31 | AC | 76 ms
52,628 KB |
testcase_32 | AC | 70 ms
51,288 KB |
testcase_33 | AC | 286 ms
53,440 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()); } }