Submission #570482

# Submission time Handle Problem Language Result Execution time Memory
570482 2022-05-30T07:09:14 Z lam Mobile (BOI12_mobile) C++14
100 / 100
415 ms 35200 KB
#include <bits/stdc++.h>
#define int long long
#define maxn 1000010
using namespace std;
int n,L;
pair<int,int> a[maxn];
typedef long double ld;
const ld eps=1e-3;
bool cmp(pair<ld,ld> x, pair<ld,ld> y)
{
    if (x.second!=y.second) return x.second<y.second;
    return x.first<y.first;
}
bool check(ld val)
{
    vector <pair<ld,ld>> b;
    b.clear();
    val*=val;
    ld curr=0.0;
    for (int i=1; i<=n; i++)
    {
        ld temp=a[i].second;
        temp=1.0*temp*temp;
        if (temp>val) continue;
        temp=val-temp;
        temp=1.0*sqrt(temp);
        ld l=a[i].first-temp;
        ld r=a[i].first+temp;
        if (l<=curr) curr=max(curr,r);
    }
    return curr>=L;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cin>>n>>L;
    for (int i=1; i<=n; i++)
    {
        cin>>a[i].first>>a[i].second;
    }
    ld l=0.0;
    ld r=2*1e9;
    ld ans=-1;
    while (r-l>eps)
    {
        ld mid=l+(r-l)/2;
        if (check(mid))
        {
            r=mid;
        }
        else
            l=mid;
    }
    cout<<fixed<<setprecision(4)<<l;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:44:8: warning: unused variable 'ans' [-Wunused-variable]
   44 |     ld ans=-1;
      |        ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 356 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1492 KB Output is correct
2 Correct 29 ms 1532 KB Output is correct
3 Correct 21 ms 1168 KB Output is correct
4 Correct 25 ms 1480 KB Output is correct
5 Correct 14 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1492 KB Output is correct
2 Correct 21 ms 1412 KB Output is correct
3 Correct 31 ms 1568 KB Output is correct
4 Correct 25 ms 1488 KB Output is correct
5 Correct 27 ms 1632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1620 KB Output is correct
2 Correct 32 ms 1492 KB Output is correct
3 Correct 29 ms 1632 KB Output is correct
4 Correct 28 ms 1832 KB Output is correct
5 Correct 27 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1776 KB Output is correct
2 Correct 50 ms 1876 KB Output is correct
3 Correct 35 ms 1868 KB Output is correct
4 Correct 33 ms 1876 KB Output is correct
5 Correct 31 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 1788 KB Output is correct
2 Correct 34 ms 1748 KB Output is correct
3 Correct 33 ms 1876 KB Output is correct
4 Correct 30 ms 1864 KB Output is correct
5 Correct 33 ms 1896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 204 ms 11392 KB Output is correct
2 Correct 191 ms 15776 KB Output is correct
3 Correct 205 ms 15312 KB Output is correct
4 Correct 168 ms 17904 KB Output is correct
5 Correct 157 ms 14928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 14572 KB Output is correct
2 Correct 249 ms 13120 KB Output is correct
3 Correct 160 ms 13896 KB Output is correct
4 Correct 161 ms 17484 KB Output is correct
5 Correct 167 ms 15448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 223 ms 13964 KB Output is correct
2 Correct 273 ms 18996 KB Output is correct
3 Correct 248 ms 18320 KB Output is correct
4 Correct 197 ms 21604 KB Output is correct
5 Correct 198 ms 17700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 218 ms 17672 KB Output is correct
2 Correct 284 ms 17640 KB Output is correct
3 Correct 188 ms 16664 KB Output is correct
4 Correct 202 ms 21452 KB Output is correct
5 Correct 188 ms 18432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 262 ms 16216 KB Output is correct
2 Correct 279 ms 22060 KB Output is correct
3 Correct 273 ms 21448 KB Output is correct
4 Correct 226 ms 24824 KB Output is correct
5 Correct 239 ms 20220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 301 ms 21028 KB Output is correct
2 Correct 297 ms 20528 KB Output is correct
3 Correct 265 ms 19636 KB Output is correct
4 Correct 219 ms 24624 KB Output is correct
5 Correct 214 ms 21392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 298 ms 18804 KB Output is correct
2 Correct 307 ms 25312 KB Output is correct
3 Correct 328 ms 24476 KB Output is correct
4 Correct 268 ms 28500 KB Output is correct
5 Correct 229 ms 24004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 313 ms 24464 KB Output is correct
2 Correct 344 ms 23472 KB Output is correct
3 Correct 268 ms 22372 KB Output is correct
4 Correct 254 ms 28264 KB Output is correct
5 Correct 246 ms 24424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 373 ms 23900 KB Output is correct
2 Correct 382 ms 31512 KB Output is correct
3 Correct 361 ms 30512 KB Output is correct
4 Correct 315 ms 35164 KB Output is correct
5 Correct 300 ms 29536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 362 ms 30964 KB Output is correct
2 Correct 415 ms 27984 KB Output is correct
3 Correct 330 ms 28264 KB Output is correct
4 Correct 310 ms 35200 KB Output is correct
5 Correct 304 ms 30620 KB Output is correct