# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56194 |
2018-07-10T08:28:47 Z |
노영훈(#1580) |
Mobile (BOI12_mobile) |
C++11 |
|
425 ms |
32960 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;
typedef pair<ll, ll> pll;
const int MX=1000010, inf=2e9;
const ll linf=5e18;
int n;
ll l;
pll P[MX];
ll sq(ll x){ return x*x; }
lf itst(pll a, pll b){
lf dm=a.first-b.first, db=a.second-b.second;
return -db/dm;
}
lf eval(pll a, lf x){
return a.first*x + a.second + x*x;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>l;
for(int i=1; i<=n; i++){
ll x, y; cin>>x>>y;
P[i]={-2*x,x*x+y*y};
}
sort(P+1, P+n+1, [](pll &a, pll &b){
if(a.first==b.first) return a.second>b.second;
return a.first>b.first;
});
// for(int i=1; i<=n; i++) cout<<P[i].first<<' '<<P[i].second<<'\n';
vector<pll> stk; // m, b
stk.push_back({0, linf});
for(int i=1; i<=n; i++){
pll now=P[i];
while(!stk.empty()){
pll prv=stk.back(); stk.pop_back();
if(now.first==prv.first) continue;
if(!stk.empty() && itst(stk.back(), prv)>=itst(prv, now)) continue;
else { stk.push_back(prv); break; }
}
stk.push_back(P[i]);
}
lf ans=0;
lf prv=-linf;
for(int i=1; i<(int)stk.size(); i++){
lf x=itst(stk[i-1], stk[i]);
// cout<<stk[i].first<<' '<<stk[i].second<<": "<<x<<'\n';
if(x<0){ prv=x; continue; }
if(prv<0){ ans=max(ans, eval(stk[i-1], 0)); }
if(x>l){ ans=max(ans, eval(stk[i-1], l)); break; }
ans=max(ans, eval(stk[i], x));
prv=x;
}
if(prv<l) ans=max(ans, eval(stk.back(), l));
/*
lf prv=-linf, ans=0;
for(int i=1; i<(int)stk.size(); i++){
lf now=itst(stk[i], stk[i-1]);
// cout<<now<<'\n';
// cout<<now<<' '<<eval(stk[i], now)<<'\n';
if(now<0) continue;
if(prv<0 && 0<=now){
prv=now;
ans=max(ans, eval(stk[i-1], 0));
}
if(l<now){
ans=max(ans, eval(stk[i-1], l));
break;
}
// cout<<now<<' '<<eval(stk[i], now)<<'\n';
ans=max(ans, eval(stk[i], now));
// cout<<'\n';
}
// cout<<'\n';
// for(int i=0; i<(int)stk.size(); i++) cout<<stk[i].first<<' '<<stk[i].second<<'\n';
// if(stk.size()==1U) ans=max({ans, eval(stk[0], 0), eval(stk[0], l)});
// if(stk.size()>1U && itst(stk[0], stk[1])<=0) ans=max(ans, eval(stk[0], 0));
// if(stk.size()>1U && itst(stk.back(), stk[stk.size()-2])>=l) ans=max(ans, eval(stk.back(), l));
*/
cout.precision(5);
cout<<fixed<<sqrtl(ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
356 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
564 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
1820 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
1820 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
4140 KB |
Output is correct |
2 |
Correct |
29 ms |
4140 KB |
Output is correct |
3 |
Correct |
25 ms |
4140 KB |
Output is correct |
4 |
Incorrect |
39 ms |
4140 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
4140 KB |
Output is correct |
2 |
Correct |
34 ms |
4140 KB |
Output is correct |
3 |
Correct |
27 ms |
4140 KB |
Output is correct |
4 |
Incorrect |
44 ms |
4140 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
4140 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
142 ms |
16692 KB |
Output is correct |
2 |
Correct |
182 ms |
16692 KB |
Output is correct |
3 |
Correct |
197 ms |
16692 KB |
Output is correct |
4 |
Incorrect |
202 ms |
16692 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
16692 KB |
Output is correct |
2 |
Incorrect |
163 ms |
16692 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
167 ms |
26488 KB |
Output is correct |
2 |
Correct |
189 ms |
26488 KB |
Output is correct |
3 |
Correct |
191 ms |
26488 KB |
Output is correct |
4 |
Incorrect |
249 ms |
26488 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
233 ms |
26488 KB |
Output is correct |
2 |
Incorrect |
220 ms |
26488 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
302 ms |
28268 KB |
Output is correct |
2 |
Correct |
309 ms |
28268 KB |
Output is correct |
3 |
Correct |
249 ms |
28268 KB |
Output is correct |
4 |
Incorrect |
383 ms |
28268 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
233 ms |
28268 KB |
Output is correct |
2 |
Incorrect |
193 ms |
28268 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
227 ms |
29792 KB |
Output is correct |
2 |
Correct |
266 ms |
29792 KB |
Output is correct |
3 |
Correct |
244 ms |
29792 KB |
Output is correct |
4 |
Incorrect |
275 ms |
29792 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
262 ms |
29792 KB |
Output is correct |
2 |
Incorrect |
258 ms |
29792 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
361 ms |
32960 KB |
Output is correct |
2 |
Correct |
360 ms |
32960 KB |
Output is correct |
3 |
Correct |
335 ms |
32960 KB |
Output is correct |
4 |
Incorrect |
425 ms |
32960 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
372 ms |
32960 KB |
Output is correct |
2 |
Incorrect |
314 ms |
32960 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |