# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
59181 |
2018-07-20T22:44:38 Z |
Benq |
Mobile (BOI12_mobile) |
C++11 |
|
325 ms |
132096 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
int N,L;
vpi v;
vector<ld> tmp;
ld perp(pd x, pd y) {
return (y.f*y.f+y.s*y.s-x.f*x.f-x.s*x.s)/(2*y.f-2*x.f);
}
ld dist(pd a, pd b) {
return sqrt(pow(a.f-b.f,2)+pow(a.s-b.s,2));
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> N >> L;
F0R(i,N) {
int x,y; cin >> x >> y; y = abs(y);
if (sz(v) && v.back().f == x) {
if (y >= v.back().s) continue;
else {
v.pop_back();
if (sz(tmp)) tmp.pop_back();
}
}
while (sz(tmp) && tmp.back() >= perp(v.back(),{x,y})) {
v.pop_back();
tmp.pop_back();
}
if (sz(v)) tmp.pb(perp(v.back(),{x,y}));
v.pb({x,y});
}
ld ans = 0;
F0R(i,sz(v)) {
ld mn = (i == 0 ? -INF : tmp[i-1]);
ld mx = (i == sz(v)-1 ? INF : tmp[i]);
if (mx < 0 || mn > L) continue;
mn = max(mn,(ld)0), mx = min(mx,(ld)L);
ans = max(ans,dist(v[i],{mn,0}));
ans = max(ans,dist(v[i],{mx,0}));
}
cout << fixed << setprecision(6) << ans;
}
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
624 KB |
Output is correct |
3 |
Correct |
2 ms |
668 KB |
Output is correct |
4 |
Correct |
3 ms |
796 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
796 KB |
Output is correct |
2 |
Correct |
3 ms |
848 KB |
Output is correct |
3 |
Correct |
3 ms |
848 KB |
Output is correct |
4 |
Correct |
3 ms |
848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
848 KB |
Output is correct |
2 |
Correct |
4 ms |
940 KB |
Output is correct |
3 |
Correct |
3 ms |
940 KB |
Output is correct |
4 |
Correct |
4 ms |
992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
992 KB |
Output is correct |
2 |
Correct |
5 ms |
1104 KB |
Output is correct |
3 |
Correct |
3 ms |
1104 KB |
Output is correct |
4 |
Correct |
4 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1272 KB |
Output is correct |
2 |
Correct |
5 ms |
1272 KB |
Output is correct |
3 |
Correct |
3 ms |
1332 KB |
Output is correct |
4 |
Correct |
5 ms |
1496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1572 KB |
Output is correct |
2 |
Correct |
4 ms |
1604 KB |
Output is correct |
3 |
Correct |
5 ms |
1604 KB |
Output is correct |
4 |
Correct |
4 ms |
1604 KB |
Output is correct |
5 |
Correct |
4 ms |
1684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
2876 KB |
Output is correct |
2 |
Correct |
30 ms |
3580 KB |
Output is correct |
3 |
Correct |
29 ms |
4300 KB |
Output is correct |
4 |
Correct |
48 ms |
5568 KB |
Output is correct |
5 |
Correct |
13 ms |
5804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
6512 KB |
Output is correct |
2 |
Correct |
29 ms |
7452 KB |
Output is correct |
3 |
Correct |
33 ms |
8392 KB |
Output is correct |
4 |
Correct |
31 ms |
9552 KB |
Output is correct |
5 |
Correct |
30 ms |
11012 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
14504 KB |
Output is correct |
2 |
Correct |
29 ms |
14504 KB |
Output is correct |
3 |
Correct |
34 ms |
16748 KB |
Output is correct |
4 |
Correct |
44 ms |
16748 KB |
Output is correct |
5 |
Correct |
31 ms |
16828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
18264 KB |
Output is correct |
2 |
Correct |
34 ms |
19780 KB |
Output is correct |
3 |
Correct |
26 ms |
21096 KB |
Output is correct |
4 |
Correct |
53 ms |
22784 KB |
Output is correct |
5 |
Correct |
31 ms |
23988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
27164 KB |
Output is correct |
2 |
Correct |
28 ms |
27164 KB |
Output is correct |
3 |
Correct |
29 ms |
28436 KB |
Output is correct |
4 |
Correct |
63 ms |
29856 KB |
Output is correct |
5 |
Correct |
36 ms |
31160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
47316 KB |
Output is correct |
2 |
Correct |
176 ms |
47316 KB |
Output is correct |
3 |
Correct |
148 ms |
50592 KB |
Output is correct |
4 |
Correct |
205 ms |
59964 KB |
Output is correct |
5 |
Correct |
159 ms |
66848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
75128 KB |
Output is correct |
2 |
Correct |
230 ms |
83212 KB |
Output is correct |
3 |
Correct |
113 ms |
89880 KB |
Output is correct |
4 |
Correct |
184 ms |
96928 KB |
Output is correct |
5 |
Correct |
165 ms |
104040 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
201 ms |
129464 KB |
Output is correct |
2 |
Correct |
199 ms |
129464 KB |
Output is correct |
3 |
Correct |
154 ms |
129464 KB |
Output is correct |
4 |
Runtime error |
256 ms |
132096 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
152 ms |
132096 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
233 ms |
132096 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
187 ms |
132096 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
259 ms |
132096 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
258 ms |
132096 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
325 ms |
132096 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
322 ms |
132096 KB |
Memory limit exceeded: We have a known bug that the memory usage is measured incorrectly (possibly because of Meltdown/Spectre patch), so your solution may be correct. Please submit again. Sorry for the inconvenience. |
2 |
Halted |
0 ms |
0 KB |
- |