結果
問題 | No.764 浮動点 |
ユーザー | hiromi_ayase |
提出日時 | 2018-12-13 13:38:07 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 346 ms / 1,500 ms |
コード長 | 3,955 bytes |
コンパイル時間 | 3,789 ms |
コンパイル使用メモリ | 90,520 KB |
実行使用メモリ | 59,844 KB |
最終ジャッジ日時 | 2024-09-25 04:27:01 |
合計ジャッジ時間 | 11,682 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 138 ms
54,132 KB |
testcase_01 | AC | 137 ms
54,072 KB |
testcase_02 | AC | 143 ms
54,316 KB |
testcase_03 | AC | 218 ms
54,872 KB |
testcase_04 | AC | 278 ms
55,428 KB |
testcase_05 | AC | 231 ms
54,684 KB |
testcase_06 | AC | 296 ms
57,836 KB |
testcase_07 | AC | 243 ms
54,768 KB |
testcase_08 | AC | 320 ms
57,968 KB |
testcase_09 | AC | 247 ms
54,904 KB |
testcase_10 | AC | 341 ms
58,484 KB |
testcase_11 | AC | 249 ms
54,928 KB |
testcase_12 | AC | 343 ms
59,592 KB |
testcase_13 | AC | 346 ms
59,844 KB |
testcase_14 | AC | 341 ms
59,512 KB |
testcase_15 | AC | 338 ms
59,768 KB |
testcase_16 | AC | 344 ms
59,628 KB |
testcase_17 | AC | 339 ms
59,660 KB |
testcase_18 | AC | 310 ms
57,752 KB |
testcase_19 | AC | 302 ms
57,652 KB |
testcase_20 | AC | 313 ms
58,300 KB |
testcase_21 | AC | 339 ms
58,160 KB |
testcase_22 | AC | 339 ms
59,528 KB |
testcase_23 | AC | 340 ms
59,556 KB |
testcase_24 | AC | 344 ms
59,504 KB |
testcase_25 | AC | 172 ms
54,520 KB |
ソースコード
public class Main { private static void solve() { int n = ni(); double d = ni(); double[] l = new double[n + 1]; for (int i = 0; i <= n; i ++) { l[i] = ni(); } //0:left min, 1:left max, 2:right min, 3:right max double[][] r = new double[n][4]; for (int i = 0; i < n; i ++) { double sumLeft = 0; double maxLeft = 0; double sumRight = 0; double maxRight = 0; for (int j = 0; j <= i; j ++) { sumLeft += l[j]; maxLeft = Math.max(maxLeft, l[j]); } for (int j = i + 1; j <= n; j ++) { sumRight += l[j]; maxRight = Math.max(maxRight, l[j]); } r[i][0] = Math.max(maxLeft * 2 - sumLeft, 0); r[i][1] = sumLeft; r[i][2] = Math.max(maxRight * 2 - sumRight, 0); r[i][3] = sumRight; } for (int i = 0; i < n; i ++) { double ret = 0; ret += s(r[i][1], r[i][3], d); ret -= s(r[i][0], r[i][3], d); ret -= s(r[i][1], r[i][2], d); ret += s(r[i][0], r[i][2], d); System.out.printf("%.9f\n", ret); } } private static double s(double r1, double r2, double d) { if (r1 + r2 <= d) return 0; if (Math.max(r1, r2) - Math.min(r1, r2) >= d) { double r = Math.min(r1, r2); return r * r * Math.PI; } double theta1 = Math.acos((r1 * r1 + d * d - r2 * r2) / (2 * r1 * d)); double theta2 = Math.acos((r2 * r2 + d * d - r1 * r1) / (2 * r2 * d)); double ret = 0; ret += r1 * r1 * (theta1 - Math.sin(theta1 * 2) / 2); ret += r2 * r2 * (theta2 - Math.sin(theta2 * 2) / 2); return ret; } public static void main(String[] args) { new Thread(null, new Runnable() { @Override public void run() { long start = System.currentTimeMillis(); String debug = args.length > 0 ? args[0] : null; if (debug != null) { try { is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug)); } catch (Exception e) { throw new RuntimeException(e); } } reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768); solve(); out.flush(); tr((System.currentTimeMillis() - start) + "ms"); } }, "", 64000000).start(); } private static java.io.InputStream is = System.in; private static java.io.PrintWriter out = new java.io.PrintWriter(System.out); private static java.util.StringTokenizer tokenizer = null; private static java.io.BufferedReader reader; public static String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new java.util.StringTokenizer(reader.readLine()); } catch (Exception e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } private static double nd() { return Double.parseDouble(next()); } private static long nl() { return Long.parseLong(next()); } private static int[] na(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = ni(); return a; } private static char[] ns() { return next().toCharArray(); } private static long[] nal(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nl(); return a; } private static int[][] ntable(int n, int m) { int[][] table = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[i][j] = ni(); } } return table; } private static int[][] nlist(int n, int m) { int[][] table = new int[m][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[j][i] = ni(); } } return table; } private static int ni() { return Integer.parseInt(next()); } private static void tr(Object... o) { if (is != System.in) System.out.println(java.util.Arrays.deepToString(o)); } }