結果
問題 | No.343 手抜き工事のプロ |
ユーザー | Grenache |
提出日時 | 2016-02-12 23:41:36 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,198 bytes |
コンパイル時間 | 4,330 ms |
コンパイル使用メモリ | 78,752 KB |
実行使用メモリ | 60,696 KB |
最終ジャッジ日時 | 2023-10-22 03:37:06 |
合計ジャッジ時間 | 7,549 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge9 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
53,660 KB |
testcase_01 | AC | 50 ms
51,652 KB |
testcase_02 | AC | 49 ms
53,664 KB |
testcase_03 | AC | 49 ms
53,652 KB |
testcase_04 | AC | 51 ms
53,652 KB |
testcase_05 | AC | 50 ms
53,664 KB |
testcase_06 | AC | 50 ms
53,656 KB |
testcase_07 | AC | 53 ms
51,644 KB |
testcase_08 | AC | 53 ms
52,528 KB |
testcase_09 | AC | 51 ms
53,656 KB |
testcase_10 | AC | 49 ms
53,652 KB |
testcase_11 | AC | 50 ms
53,656 KB |
testcase_12 | AC | 53 ms
53,664 KB |
testcase_13 | WA | - |
testcase_14 | AC | 60 ms
53,716 KB |
testcase_15 | AC | 70 ms
54,216 KB |
testcase_16 | AC | 50 ms
51,656 KB |
testcase_17 | AC | 54 ms
53,660 KB |
testcase_18 | AC | 50 ms
53,660 KB |
testcase_19 | AC | 50 ms
53,660 KB |
testcase_20 | AC | 115 ms
56,560 KB |
testcase_21 | AC | 147 ms
58,856 KB |
testcase_22 | WA | - |
testcase_23 | AC | 165 ms
58,984 KB |
testcase_24 | AC | 184 ms
58,548 KB |
testcase_25 | AC | 185 ms
58,588 KB |
testcase_26 | AC | 193 ms
59,060 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; public class Main_yukicoder343 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); int l = sc.nextInt(); int[] x = new int[n]; for (int i = 1; i < n; i++) { x[i] = sc.nextInt(); } if (n == 1) { pr.println(0); } else { double h = (double)l / 2; double g = x[n - 1]; int ret = 0; for (int i = n - 2; i >= 0; i--) { if (Math.abs(x[i + 1] - x[i]) >= l) { ret = -1; break; } else if ((g <= (double)x[i] - h || g >= (double)x[i] + h) || (g <= (double)x[i + 1] - h || g >= (double)x[i + 1] + h)) { ret++; } g = (g * (n - 1 - i) + x[i]) / (n - 1 - i + 1); } pr.println(ret); } pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }