Submission #1057609

# Submission time Handle Problem Language Result Execution time Memory
1057609 2024-08-14T00:19:27 Z lucascgar Mobile (BOI12_mobile) C++17
100 / 100
564 ms 35316 KB
#include <bits/stdc++.h>

// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

using namespace std;

/*
chutar resposta x:
na ordem dada se torre pega ponto r, atualizar r pro maior ponto com distância menor que x
(ordem é sempre ótima pq se um cara à direita é melhor que um à esquerda p atingir r, então ele é melhor pra ir p direita tb)
se nn chguei até l, deu errado
se não, nn é

achar pontos p torre: busca binária

pitágoras p nn dar TLE:
p[i].second^2 + ex^2 = x^2
ex^2 = x^2 - p[i].second^2
ex = sqrt(x^2 - p[i].second^2)

*/

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); // overclock random

typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;

const int MAXN = 1e6+10;
const double PRECISION = 1e-5;

long double dist(pdd a, pdd b){
    long double x = abs(a.first-b.first), y = abs(a.second-b.second);
    return x*x + y*y;
}

pll p[MAXN];
int l;

signed main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    cout << fixed << setprecision(6);

    int n;
    cin >> n >> l;

    for (int i=0;i<n;i++){
        cin >> p[i].first >> p[i].second;
    }

    long double in=0, fi = 2e9, me;

    for (int q=0;q<100;q++){
        me = (in+fi)/2.00;
        long double sq = me*me;
        long double r=0;
        bool vl = 1;
        for (int i=0;i<n;i++){
            if (dist(p[i], {r, 0}) <= sq){
                vl=0;
                if (dist(p[i], {l, 0}) <= sq) r=l;
                else{
                    // pitagoras
                    long double ex = sqrtl(sq - (p[i].second*p[i].second));
                    if (p[i].first+ex > r) r = p[i].first+ex;
                }
            }
            if (r==l) break;
        }


        vl = vl || (l!=r);
        if (vl) in=me;
        else fi=me;

    }

    cout << in << '\n';

    return 0;
}   
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 2808 KB Output is correct
2 Correct 13 ms 2652 KB Output is correct
3 Correct 10 ms 2652 KB Output is correct
4 Correct 20 ms 2652 KB Output is correct
5 Correct 11 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2696 KB Output is correct
2 Correct 17 ms 2648 KB Output is correct
3 Correct 24 ms 2652 KB Output is correct
4 Correct 21 ms 2652 KB Output is correct
5 Correct 24 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2652 KB Output is correct
2 Correct 17 ms 3676 KB Output is correct
3 Correct 18 ms 3660 KB Output is correct
4 Correct 30 ms 4600 KB Output is correct
5 Correct 20 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2652 KB Output is correct
2 Correct 16 ms 2652 KB Output is correct
3 Correct 18 ms 2700 KB Output is correct
4 Correct 30 ms 2700 KB Output is correct
5 Correct 24 ms 2696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 2652 KB Output is correct
2 Correct 17 ms 2704 KB Output is correct
3 Correct 20 ms 2652 KB Output is correct
4 Correct 34 ms 2652 KB Output is correct
5 Correct 24 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 275 ms 8796 KB Output is correct
2 Correct 89 ms 16340 KB Output is correct
3 Correct 101 ms 15988 KB Output is correct
4 Correct 158 ms 18256 KB Output is correct
5 Correct 131 ms 15700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 8824 KB Output is correct
2 Correct 251 ms 8784 KB Output is correct
3 Correct 94 ms 14420 KB Output is correct
4 Correct 143 ms 18000 KB Output is correct
5 Correct 125 ms 15984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 336 ms 10832 KB Output is correct
2 Correct 102 ms 20052 KB Output is correct
3 Correct 93 ms 19536 KB Output is correct
4 Correct 175 ms 22636 KB Output is correct
5 Correct 156 ms 18744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 10836 KB Output is correct
2 Correct 256 ms 10832 KB Output is correct
3 Correct 120 ms 17652 KB Output is correct
4 Correct 180 ms 22504 KB Output is correct
5 Correct 157 ms 19536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 411 ms 12880 KB Output is correct
2 Correct 119 ms 23636 KB Output is correct
3 Correct 108 ms 22868 KB Output is correct
4 Correct 201 ms 26452 KB Output is correct
5 Correct 169 ms 21960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 169 ms 12880 KB Output is correct
2 Correct 299 ms 12940 KB Output is correct
3 Correct 141 ms 21076 KB Output is correct
4 Correct 213 ms 26100 KB Output is correct
5 Correct 177 ms 22900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 442 ms 14932 KB Output is correct
2 Correct 144 ms 27368 KB Output is correct
3 Correct 115 ms 26448 KB Output is correct
4 Correct 236 ms 30544 KB Output is correct
5 Correct 209 ms 25936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 143 ms 14972 KB Output is correct
2 Correct 330 ms 14972 KB Output is correct
3 Correct 167 ms 24400 KB Output is correct
4 Correct 231 ms 30444 KB Output is correct
5 Correct 220 ms 26448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 564 ms 15956 KB Output is correct
2 Correct 216 ms 31608 KB Output is correct
3 Correct 165 ms 30548 KB Output is correct
4 Correct 294 ms 35180 KB Output is correct
5 Correct 249 ms 29520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 247 ms 15956 KB Output is correct
2 Correct 427 ms 16012 KB Output is correct
3 Correct 210 ms 28144 KB Output is correct
4 Correct 279 ms 35316 KB Output is correct
5 Correct 258 ms 30804 KB Output is correct