# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72463 | 2018-08-26T08:20:46 Z | 유애나(#2199, kdh9949) | Hill Reconstruction (FXCUP3_hill) | C++17 | 348 ms | 5424 KB |
#include <bits/stdc++.h> using namespace std; using ld = long double; using ll = long long; const int N = 300005, TRIAL = 70; int n; ll a[N], b[N], c, mb, ma; int f(ld x){ mb = 0; ma = 1; int lst = n - 1; ll s = 0, cs = 0; for(int i = n - 2; i >= 0; i--){ cs += (a[i] * b[i + 1] - b[i] * a[i + 1]); if(ld(b[lst] - b[i]) / (a[lst] - a[i]) <= x){ cs += (a[lst] * b[i] - b[lst] * a[i]); s += abs(cs); if(ma * (b[lst] - b[i]) > mb * (a[lst] - a[i])){ mb = b[lst] - b[i]; ma = a[lst] - a[i]; } lst = i; cs = 0; } if(s > 2 * c) return 0; } return !lst; } int main(){ scanf("%d%lld", &n, &c); for(int i = 0; i < n; i++) scanf("%lld", a + i); for(int i = 0; i < n; i++) scanf("%lld", b + i); ld l = 0, r = 1e9; for(int i = 0; i < TRIAL; i++){ ld m = (l + r) / 2; if(f(m)) r = m; else l = m; } f(l + 1e-9); printf("%lld/%lld\n", mb / gcd(mb, ma), ma / gcd(mb, ma)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 436 KB | Output is correct |
4 | Correct | 3 ms | 492 KB | Output is correct |
5 | Correct | 3 ms | 604 KB | Output is correct |
6 | Correct | 3 ms | 604 KB | Output is correct |
7 | Correct | 3 ms | 604 KB | Output is correct |
8 | Correct | 3 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 436 KB | Output is correct |
4 | Correct | 3 ms | 492 KB | Output is correct |
5 | Correct | 3 ms | 604 KB | Output is correct |
6 | Correct | 3 ms | 604 KB | Output is correct |
7 | Correct | 3 ms | 604 KB | Output is correct |
8 | Correct | 3 ms | 604 KB | Output is correct |
9 | Correct | 316 ms | 5280 KB | Output is correct |
10 | Correct | 272 ms | 5280 KB | Output is correct |
11 | Correct | 268 ms | 5308 KB | Output is correct |
12 | Correct | 348 ms | 5424 KB | Output is correct |
13 | Correct | 172 ms | 5424 KB | Output is correct |
14 | Correct | 120 ms | 5424 KB | Output is correct |
15 | Correct | 205 ms | 5424 KB | Output is correct |
16 | Correct | 234 ms | 5424 KB | Output is correct |
17 | Correct | 173 ms | 5424 KB | Output is correct |
18 | Correct | 197 ms | 5424 KB | Output is correct |
19 | Correct | 265 ms | 5424 KB | Output is correct |