結果
問題 | No.764 浮動点 |
ユーザー | te-sh |
提出日時 | 2018-12-12 16:22:33 |
言語 | D (dmd 2.106.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,465 bytes |
コンパイル時間 | 2,807 ms |
コンパイル使用メモリ | 155,020 KB |
実行使用メモリ | 14,008 KB |
最終ジャッジ日時 | 2024-06-13 02:15:13 |
合計ジャッジ時間 | 41,016 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
9,116 KB |
testcase_01 | AC | 5 ms
6,940 KB |
testcase_02 | AC | 23 ms
6,940 KB |
testcase_03 | AC | 560 ms
6,944 KB |
testcase_04 | TLE | - |
testcase_05 | AC | 654 ms
6,940 KB |
testcase_06 | TLE | - |
testcase_07 | AC | 757 ms
6,944 KB |
testcase_08 | TLE | - |
testcase_09 | AC | 855 ms
6,944 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 963 ms
6,944 KB |
testcase_12 | TLE | - |
testcase_13 | TLE | - |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | TLE | - |
testcase_17 | TLE | - |
testcase_18 | TLE | - |
testcase_19 | TLE | - |
testcase_20 | TLE | - |
testcase_21 | TLE | - |
testcase_22 | TLE | - |
testcase_23 | TLE | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}} void main() { int n; readV(n); double[] l; readC(n+2, l); auto l0 = l[0], lc = l.cumulativeSum; auto ll = new double[](n+2), lr = new double[](n+2); ll[1] = l[1]; foreach (i; 2..n+2) ll[i] = max(ll[i-1], l[i]); lr[n+1] = l[n+1]; foreach_reverse (i; 1..n+1) lr[i] = max(lr[i+1], l[i]); writeln(0); foreach (i; 2..n) { auto a = lc[1..i+1], b = max(2*ll[i]-a, 0); auto c = lc[i+1..$], d = max(2*lr[i+1]-c, 0); double f(double x) { auto ay = 0.0L, by = 0.0L, cy = 0.0L, dy = 0.0L; if (-a < x && x < a) ay = sqrt(a^^2-x^^2); if (-b < x && x < b) by = sqrt(b^^2-x^^2); if (l0-c < x && x < l0+c) cy = sqrt(c^^2-(x-l0)^^2); if (l0-d < x && x < l0+d) dy = sqrt(d^^2-(x-l0)^^2); return max(0.0L, min(ay, cy)-max(by, dy)); } writefln("%.7f", integrate!double((x) => f(x), -a, l0+c, 1e-6)*2); } writeln(0); } class CumulativeSum(T) { size_t n; T[] s; this(T[] a) { n = a.length; s = new T[](n+1); s[0] = T(0); foreach (i; 0..n) s[i+1] = s[i] + a[i]; } T opSlice(size_t l, size_t r) { return s[r]-s[l]; } size_t opDollar() { return n; } } auto cumulativeSum(T)(T[] a) { return new CumulativeSum!T(a); } T integrate(T)(T delegate(T) f, T lo, T hi, T eps = 1e-8) { import std.math; const auto th = eps / 1e-14; T rec(T x0, T x6, T y0, T y6, int d) { const auto a = sqrt(2.0/3.0), b = 1.0 / sqrt(5.0); auto x3 = (x0+x6)/2, y3 = f(x3), h = (x6-x0)/2; auto x1 = x3-a*h, x2 = x3-b*h, x4 = x3+b*h, x5 = x3+a*h; auto y1 = f(x1), y2 = f(x2), y4 = f(x4), y5 = f(x5); auto i1 = (y0 + y6 + (y2 + y4) * 5) * (h/6); auto i2 = ((y0 + y6) * 77 + (y1 + y5) * 432 + (y2 + y4) * 625 + y3 * 672) * (h/1470); if (x3 + h == x3 || d > 50) return 0.0; if (d > 4 && th + (i1 - i2) == th) return i2; return rec(x0, x1, y0, y1, d+1) + rec(x1, x2, y1, y2, d+1) + rec(x2, x3, y2, y3, d+1) + rec(x3, x4, y3, y4, d+1) + rec(x4, x5, y4, y5, d+1) + rec(x5, x6, y5, y6, d+1); } return rec(lo, hi, f(lo), f(hi), 0); }