結果
問題 | No.496 ワープクリスタル (給料日前編) |
ユーザー | shinwisteria |
提出日時 | 2017-03-26 13:03:29 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,250 bytes |
コンパイル時間 | 5,049 ms |
コンパイル使用メモリ | 75,252 KB |
実行使用メモリ | 57,740 KB |
最終ジャッジ日時 | 2023-09-20 10:59:05 |
合計ジャッジ時間 | 8,845 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 124 ms
55,668 KB |
testcase_01 | AC | 128 ms
55,608 KB |
testcase_02 | AC | 127 ms
56,004 KB |
testcase_03 | AC | 124 ms
55,832 KB |
testcase_04 | WA | - |
testcase_05 | AC | 125 ms
56,024 KB |
testcase_06 | AC | 124 ms
55,844 KB |
testcase_07 | AC | 121 ms
55,600 KB |
testcase_08 | AC | 139 ms
56,160 KB |
testcase_09 | AC | 135 ms
55,712 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
ソースコード
import java.util.ArrayList; import java.util.Scanner; public class WarpCrystal { public static void main(String[] args) { Scanner s = new Scanner(System.in); int Gx = s.nextInt() , Gy = s.nextInt() , N = s.nextInt() , F = s.nextInt(); int sx = 0,sy = 0; ArrayList<Integer>[] crystal = new ArrayList[N]; for(int i = 0;i < N;i++){ crystal[i] = new ArrayList<Integer>(); crystal[i].add(s.nextInt()); crystal[i].add(s.nextInt()); crystal[i].add(s.nextInt()); } int cost = (Gx + Gy) * F, cost0 = cost; while(sx != Gx || sy != Gy){ //System.out.println(sx + " " + sy); int kn = -1; for(int i = 0;i < N;i++){ int x = crystal[i].get(0); int y = crystal[i].get(1); int c = crystal[i].get(2); if(c != 0){ if(sx + x <= Gx && sy + y <= Gy && cost > cost0 + c - (x+y)*F){ //System.out.print("更新" + x + " " + y + " " + cost); cost += c-(x+y)*F; kn = i; //System.out.println(" " + cost); }else if(c >= (x+y)*F){ crystal[i].set(2, 0); } } } if(kn != -1){ crystal[kn].set(2, 0); sx += crystal[kn].get(0); sy += crystal[kn].get(1); cost0 = cost; }else{ sx = Gx; sy = Gy; } } s.close(); System.out.println(cost); } }