結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー | chocorusk |
提出日時 | 2020-10-04 13:35:24 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,925 bytes |
コンパイル時間 | 2,844 ms |
コンパイル使用メモリ | 78,812 KB |
実行使用メモリ | 56,820 KB |
最終ジャッジ日時 | 2023-09-26 16:28:33 |
合計ジャッジ時間 | 8,220 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 127 ms
55,400 KB |
testcase_01 | AC | 127 ms
56,268 KB |
testcase_02 | AC | 127 ms
55,416 KB |
testcase_03 | AC | 126 ms
56,032 KB |
testcase_04 | WA | - |
testcase_05 | AC | 128 ms
55,964 KB |
testcase_06 | AC | 128 ms
55,952 KB |
testcase_07 | AC | 126 ms
55,640 KB |
testcase_08 | AC | 165 ms
56,148 KB |
testcase_09 | AC | 165 ms
56,820 KB |
testcase_10 | AC | 142 ms
55,920 KB |
testcase_11 | AC | 141 ms
55,944 KB |
testcase_12 | AC | 140 ms
56,288 KB |
testcase_13 | AC | 137 ms
55,668 KB |
testcase_14 | AC | 140 ms
55,764 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 141 ms
55,768 KB |
testcase_19 | WA | - |
testcase_20 | AC | 135 ms
56,000 KB |
testcase_21 | AC | 133 ms
55,884 KB |
testcase_22 | WA | - |
testcase_23 | AC | 162 ms
55,884 KB |
testcase_24 | AC | 163 ms
56,244 KB |
testcase_25 | AC | 162 ms
56,704 KB |
testcase_26 | AC | 162 ms
55,684 KB |
ソースコード
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.NoSuchElementException; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //FastScanner scanner=new FastScanner(); PrintWriter out = new PrintWriter(System.out); int gx=scanner.nextInt(); int gy=scanner.nextInt(); int n=scanner.nextInt(); int f=scanner.nextInt(); final int INF=1000000; int[][] d=new int[gx+1][gy+1]; for(int i=0; i<=gx; i++) Arrays.fill(d[i], INF); d[0][0]=0; int[] x=new int[n]; int[] y=new int[n]; int[] c=new int[n]; for(int i=0; i<n; i++) { x[i]=scanner.nextInt(); y[i]=scanner.nextInt(); c[i]=scanner.nextInt(); } for(int i=0; i<=gx; i++) { for(int j=0; j<=gy; j++) { if(i+1<=gx) { d[i+1][j]=Math.min(d[i+1][j], d[i][j]+f); } if(j+1<=gy) { d[i][j+1]=Math.min(d[i][j+1], d[i][j]+f); } for(int k=0; k<n; k++) { if(i+x[k]<=gx && j+y[k]<=gy) { d[i+x[k]][j+y[k]]=Math.min(d[i+x[k]][j+y[k]], d[i][j]+c[k]); } } } } out.println(d[gx][gy]); out.close(); scanner.close(); } } class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int buflen = 0; private boolean hasNextByte() { if (ptr < buflen) { return true; } else { ptr = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } public boolean hasNext() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); return (int) nl; } public double nextDouble() { return Double.parseDouble(next()); } }