結果
問題 | No.5017 Tool-assisted Shooting |
ユーザー | EvbCFfp1XB |
提出日時 | 2023-07-16 17:30:59 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 558 ms / 2,000 ms |
コード長 | 6,912 bytes |
コンパイル時間 | 2,418 ms |
コンパイル使用メモリ | 83,528 KB |
実行使用メモリ | 86,776 KB |
スコア | 3,656,905 |
平均クエリ数 | 3790.94 |
最終ジャッジ日時 | 2023-07-16 17:32:03 |
合計ジャッジ時間 | 60,444 ms |
ジャッジサーバーID (参考情報) |
judge17 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 503 ms
78,288 KB |
testcase_01 | AC | 504 ms
84,536 KB |
testcase_02 | AC | 515 ms
84,248 KB |
testcase_03 | AC | 544 ms
85,400 KB |
testcase_04 | AC | 558 ms
84,524 KB |
testcase_05 | AC | 515 ms
82,764 KB |
testcase_06 | AC | 548 ms
80,964 KB |
testcase_07 | AC | 497 ms
84,984 KB |
testcase_08 | AC | 490 ms
84,968 KB |
testcase_09 | AC | 497 ms
84,240 KB |
testcase_10 | AC | 526 ms
84,880 KB |
testcase_11 | AC | 480 ms
83,648 KB |
testcase_12 | AC | 461 ms
80,808 KB |
testcase_13 | AC | 519 ms
82,700 KB |
testcase_14 | AC | 460 ms
82,328 KB |
testcase_15 | AC | 502 ms
85,196 KB |
testcase_16 | AC | 499 ms
80,248 KB |
testcase_17 | AC | 542 ms
84,872 KB |
testcase_18 | AC | 495 ms
83,964 KB |
testcase_19 | AC | 506 ms
83,288 KB |
testcase_20 | AC | 497 ms
84,860 KB |
testcase_21 | AC | 492 ms
84,828 KB |
testcase_22 | AC | 528 ms
82,768 KB |
testcase_23 | AC | 491 ms
84,056 KB |
testcase_24 | AC | 514 ms
85,224 KB |
testcase_25 | AC | 475 ms
80,848 KB |
testcase_26 | AC | 540 ms
84,752 KB |
testcase_27 | AC | 507 ms
84,364 KB |
testcase_28 | AC | 525 ms
83,744 KB |
testcase_29 | AC | 497 ms
84,780 KB |
testcase_30 | AC | 486 ms
84,264 KB |
testcase_31 | AC | 511 ms
85,200 KB |
testcase_32 | AC | 528 ms
80,092 KB |
testcase_33 | AC | 501 ms
85,352 KB |
testcase_34 | AC | 472 ms
82,176 KB |
testcase_35 | AC | 527 ms
84,436 KB |
testcase_36 | AC | 493 ms
84,104 KB |
testcase_37 | AC | 519 ms
83,124 KB |
testcase_38 | AC | 502 ms
84,860 KB |
testcase_39 | AC | 536 ms
85,132 KB |
testcase_40 | AC | 523 ms
85,192 KB |
testcase_41 | AC | 497 ms
80,056 KB |
testcase_42 | AC | 527 ms
84,648 KB |
testcase_43 | AC | 501 ms
85,188 KB |
testcase_44 | AC | 504 ms
80,564 KB |
testcase_45 | AC | 478 ms
79,848 KB |
testcase_46 | AC | 502 ms
85,868 KB |
testcase_47 | AC | 493 ms
84,856 KB |
testcase_48 | AC | 515 ms
85,064 KB |
testcase_49 | AC | 530 ms
86,264 KB |
testcase_50 | AC | 476 ms
85,188 KB |
testcase_51 | AC | 519 ms
84,096 KB |
testcase_52 | AC | 494 ms
82,208 KB |
testcase_53 | AC | 503 ms
85,156 KB |
testcase_54 | AC | 499 ms
85,120 KB |
testcase_55 | AC | 496 ms
84,756 KB |
testcase_56 | AC | 456 ms
80,228 KB |
testcase_57 | AC | 477 ms
84,980 KB |
testcase_58 | AC | 503 ms
85,188 KB |
testcase_59 | AC | 490 ms
85,424 KB |
testcase_60 | AC | 517 ms
84,928 KB |
testcase_61 | AC | 479 ms
84,812 KB |
testcase_62 | AC | 482 ms
84,068 KB |
testcase_63 | AC | 487 ms
79,888 KB |
testcase_64 | AC | 477 ms
83,920 KB |
testcase_65 | AC | 543 ms
85,004 KB |
testcase_66 | AC | 492 ms
84,708 KB |
testcase_67 | AC | 526 ms
84,080 KB |
testcase_68 | AC | 488 ms
84,816 KB |
testcase_69 | AC | 528 ms
80,480 KB |
testcase_70 | AC | 462 ms
84,596 KB |
testcase_71 | AC | 463 ms
82,620 KB |
testcase_72 | AC | 500 ms
85,024 KB |
testcase_73 | AC | 495 ms
84,620 KB |
testcase_74 | AC | 522 ms
84,984 KB |
testcase_75 | AC | 503 ms
85,476 KB |
testcase_76 | AC | 520 ms
84,936 KB |
testcase_77 | AC | 513 ms
84,664 KB |
testcase_78 | AC | 510 ms
84,716 KB |
testcase_79 | AC | 476 ms
84,988 KB |
testcase_80 | AC | 517 ms
84,552 KB |
testcase_81 | AC | 521 ms
85,012 KB |
testcase_82 | AC | 495 ms
85,500 KB |
testcase_83 | AC | 497 ms
85,072 KB |
testcase_84 | AC | 506 ms
84,672 KB |
testcase_85 | AC | 521 ms
84,492 KB |
testcase_86 | AC | 488 ms
85,700 KB |
testcase_87 | AC | 501 ms
85,704 KB |
testcase_88 | AC | 485 ms
84,408 KB |
testcase_89 | AC | 510 ms
84,616 KB |
testcase_90 | AC | 526 ms
84,408 KB |
testcase_91 | AC | 496 ms
84,212 KB |
testcase_92 | AC | 513 ms
84,664 KB |
testcase_93 | AC | 487 ms
86,776 KB |
testcase_94 | AC | 486 ms
84,660 KB |
testcase_95 | AC | 484 ms
84,688 KB |
testcase_96 | AC | 457 ms
80,264 KB |
testcase_97 | AC | 520 ms
84,184 KB |
testcase_98 | AC | 481 ms
85,552 KB |
testcase_99 | AC | 525 ms
85,272 KB |
ソースコード
import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.List; import java.util.Scanner; public final class Main { private static final int maxTurn = 1000; private static final int Y = 60; private static final int X = 25; public static final void main(final String[] args) { new Main().run(); } private void run() { Enemy[][] board = new Enemy[Y + 1][X]; int playerX = 12; int sumP = 0; int score = 0; try (final Scanner in = new Scanner(System.in)) { for (int turn = 0; turn < maxTurn; turn++) { StringBuilder res = new StringBuilder(); for (int x = 0; x < X; x++) { for (int y = 0; y < Y; y++) { board[y][x] = board[y + 1][x]; } board[Y][x] = null; } int n = in.nextInt(); if (n < 0) { break; } for (int i = 0; i < n; i++) { int h = in.nextInt(); int p = in.nextInt(); int x = in.nextInt(); board[Y - 1][x] = new Enemy(h, p); } if (isUnderAttack(board, playerX)) { res.append("S").append("\n"); } else { int best = -(int) 1e9; int bestP = (int) 1e9; int bestY = (int) 1e9; int bestX = (int) 1e9; for (int x = 0; x < 25; x++) { for (int y = 0; y < 60; y++) { if (board[y][x] == null) { continue; } final int turn2 = distance(playerX, x) + 1 + board[y][x].h / (1 + sumP / 100); if (turn2 < y) { int count = 0; for (int y2 = y; y2 < Y; y2++) { if (board[y2][x] != null) { count += board[y2][x].p; } } final int evaluation = turn2 * -10000 + count * 10; if (evaluation > best) { best = evaluation; bestP = board[y][x].p; bestY = y; bestX = x; } else if (evaluation == best && board[y][x].p > bestP) { best = evaluation; bestP = board[y][x].p; bestY = y; bestX = x; } } break; } } res.append("#" + Utils.toString("turn", turn, "best", best)).append("\n"); res.append("#" + Utils.toString("x", bestX)).append("\n"); res.append("#" + Utils.toString("y", bestY)).append("\n"); if (board[0][playerX] == null && board[1][playerX] == null && playerX == bestX) { res.append("S").append("\n"); } else if (board[0][(playerX - 1 + 25) % 25] == null && board[1][(playerX - 1 + 25) % 25] == null && distance((playerX - 1 + 25) % 25, bestX) < distance((playerX + 1) % 25, bestX)) { res.append("L").append("\n"); playerX = (playerX - 1 + 25) % 25; } else if (board[0][(playerX + 1) % 25] == null && board[1][(playerX + 1) % 25] == null && distance((playerX - 1 + 25) % 25, bestX) > distance((playerX + 1) % 25, bestX)) { res.append("R").append("\n"); playerX = (playerX + 1) % 25; } else { if (board[0][playerX] == null && board[1][playerX] == null) { res.append("S").append("\n"); } else if (board[0][(playerX - 1 + 25) % 25] == null && board[1][(playerX - 1 + 25) % 25] == null) { res.append("L").append("\n"); playerX = (playerX - 1 + 25) % 25; } else if (board[0][(playerX + 1) % 25] == null && board[1][(playerX + 1) % 25] == null) { res.append("R").append("\n"); playerX = (playerX + 1) % 25; } } } int level = 1 + sumP / 100; for (int y = 0; y < 60; y++) { if (board[y][playerX] == null) { continue; } board[y][playerX].h -= level; if (board[y][playerX].h <= 0) { sumP += board[y][playerX].p; score += board[y][playerX].h0; res.append("#" + Utils.toString("turn", turn, "H", board[y][playerX].h, "sumP", sumP, "score", score)).append("\n"); board[y][playerX] = null; } else { res.append("#" + Utils.toString("turn", turn, "H", board[y][playerX].h, "sumP", sumP, "score", score)).append("\n"); } break; } System.out.println(res.toString().trim()); System.out.flush(); } } } private boolean isUnderAttack(Enemy[][] board, int x) { for (int y = 0; y < 60; y++) { if (board[y][x] == null) { continue; } if (board[y][x].h != board[y][x].h0) { if (board[y][x].h < y) { return true; } } break; } return false; } private int distance(int x, int x2) { return Math.min(Math.abs(x - x2), Math.abs((x + 25) - x2)); } } class Enemy { int h; int h0; int p; Enemy(int h, int p) { this.h = h; this.h0 = h; this.p = p; } } class Utils { private Utils() { } public static final void debug(Object... o) { System.err.println(toString(o)); System.err.flush(); } public static final String toString(Object... o) { return Arrays.deepToString(o); } public static boolean isValid(int v, int min, int minUpper) { return v >= min && v < minUpper; } }