結果
問題 | No.2521 Don't be Same |
ユーザー | ks2m |
提出日時 | 2023-10-27 23:49:03 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 220 ms / 2,000 ms |
コード長 | 1,651 bytes |
コンパイル時間 | 3,127 ms |
コンパイル使用メモリ | 84,840 KB |
実行使用メモリ | 74,136 KB |
平均クエリ数 | 9.93 |
最終ジャッジ日時 | 2023-10-27 23:49:16 |
合計ジャッジ時間 | 10,377 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 220 ms
73,088 KB |
testcase_01 | AC | 185 ms
74,136 KB |
testcase_02 | AC | 204 ms
73,792 KB |
testcase_03 | AC | 185 ms
72,816 KB |
testcase_04 | AC | 181 ms
72,844 KB |
testcase_05 | AC | 200 ms
73,984 KB |
testcase_06 | AC | 179 ms
72,856 KB |
testcase_07 | AC | 202 ms
74,124 KB |
testcase_08 | AC | 184 ms
72,848 KB |
testcase_09 | AC | 186 ms
72,856 KB |
testcase_10 | AC | 158 ms
72,760 KB |
testcase_11 | AC | 184 ms
73,080 KB |
testcase_12 | AC | 171 ms
73,964 KB |
testcase_13 | AC | 171 ms
73,888 KB |
testcase_14 | AC | 155 ms
72,180 KB |
testcase_15 | AC | 168 ms
73,016 KB |
testcase_16 | AC | 170 ms
73,716 KB |
testcase_17 | AC | 168 ms
72,128 KB |
testcase_18 | AC | 163 ms
73,064 KB |
testcase_19 | AC | 162 ms
72,776 KB |
testcase_20 | AC | 180 ms
72,452 KB |
testcase_21 | AC | 193 ms
73,140 KB |
testcase_22 | AC | 197 ms
72,008 KB |
testcase_23 | AC | 200 ms
73,128 KB |
testcase_24 | AC | 192 ms
73,976 KB |
testcase_25 | AC | 193 ms
74,072 KB |
testcase_26 | AC | 198 ms
73,624 KB |
testcase_27 | AC | 201 ms
71,432 KB |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int y = sc.nextInt(); int a = Math.min(x, y); int b = Math.max(x, y); boolean f = true; if (a + 1 == b && a % 2 == 1) { f = false; } if (f) { System.out.println("First"); if (x == y) { System.out.println("B"); x = 0; y = 0; } else if (x > y) { int r = 0; if (y == 0) { r = x; } else if (y % 2 == 0) { r = x - y + 1; } else { r = x - y - 1; } System.out.println("A 1 " + r); x -= r; } else { int r = 0; if (x == 0) { r = y; } else if (x % 2 == 0) { r = y - x + 1; } else { r = y - x - 1; } System.out.println("A 2 " + r); y -= r; } } else { System.out.println("Second"); } while (true) { String s = sc.next(); if (s.equals("C") || s.equals("D")) { break; } if (s.equals("B")) { x = 0; y = 0; } else { int i = sc.nextInt(); int n = sc.nextInt(); if (i == 1) { x -= n; } else { y -= n; } } if (x == y) { System.out.println("B"); x = 0; y = 0; } else if (x > y) { int r = 0; if (y == 0) { r = x; } else if (y % 2 == 0) { r = x - y + 1; } else { r = x - y - 1; } System.out.println("A 1 " + r); x -= r; } else { int r = 0; if (x == 0) { r = y; } else if (x % 2 == 0) { r = y - x + 1; } else { r = y - x - 1; } System.out.println("A 2 " + r); y -= r; } } sc.close(); } }