結果
問題 | No.343 手抜き工事のプロ |
ユーザー | Grenache |
提出日時 | 2016-02-13 00:01:01 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 208 ms / 2,000 ms |
コード長 | 2,173 bytes |
コンパイル時間 | 4,451 ms |
コンパイル使用メモリ | 78,940 KB |
実行使用メモリ | 60,008 KB |
最終ジャッジ日時 | 2023-10-22 03:44:23 |
合計ジャッジ時間 | 7,956 ms |
ジャッジサーバーID (参考情報) |
judge9 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
53,688 KB |
testcase_01 | AC | 55 ms
53,696 KB |
testcase_02 | AC | 55 ms
53,712 KB |
testcase_03 | AC | 55 ms
52,524 KB |
testcase_04 | AC | 55 ms
53,704 KB |
testcase_05 | AC | 54 ms
51,752 KB |
testcase_06 | AC | 55 ms
53,692 KB |
testcase_07 | AC | 55 ms
53,688 KB |
testcase_08 | AC | 54 ms
52,556 KB |
testcase_09 | AC | 57 ms
52,536 KB |
testcase_10 | AC | 56 ms
51,648 KB |
testcase_11 | AC | 56 ms
53,704 KB |
testcase_12 | AC | 57 ms
53,696 KB |
testcase_13 | AC | 123 ms
56,056 KB |
testcase_14 | AC | 66 ms
54,292 KB |
testcase_15 | AC | 66 ms
53,836 KB |
testcase_16 | AC | 56 ms
53,692 KB |
testcase_17 | AC | 55 ms
53,696 KB |
testcase_18 | AC | 56 ms
53,696 KB |
testcase_19 | AC | 55 ms
53,712 KB |
testcase_20 | AC | 121 ms
56,288 KB |
testcase_21 | AC | 150 ms
58,468 KB |
testcase_22 | AC | 156 ms
59,848 KB |
testcase_23 | AC | 187 ms
59,836 KB |
testcase_24 | AC | 196 ms
60,008 KB |
testcase_25 | AC | 202 ms
58,580 KB |
testcase_26 | AC | 208 ms
59,024 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; int g = x[n - 1]; int ret = 0; for (int i = n - 2; i >= 0; i--) { int m = n - 1 - i; if (Math.abs(x[i + 1] - x[i]) >= l) { ret = -1; break; } else if (Math.abs((double)x[i] - (double)g / m) >= h || Math.abs((double)x[i + 1] - (double)g / m) >= h) { ret++; } g += x[i]; } 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); } } }