Submission #847636

# Submission time Handle Problem Language Result Execution time Memory
847636 2023-09-10T05:46:22 Z hariaakas646 Mobile (BOI12_mobile) C++17
100 / 100
849 ms 35408 KB
#include <bits/stdc++.h>

using namespace std;

#define scd(t) scanf("%d", &t)
#define scld(t) scanf("%ld", &t)
#define sclld(t) scanf("%lld", &t)
#define scc(t) scanf("%c", &t)
#define scs(t) scanf("%s", t)
#define scf(t) scanf("%f", &t)
#define sclf(t) scanf("%lf", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long int li;
typedef unsigned long int uli;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;

void usaco()
{
    freopen("input.in", "r", stdin);
//    freopen("problem.out", "w", stdout);
}

int n;
lli l;
vector<pair<lli, lli>> vec;

ld dist(ld x1, ld y1, ld x2, ld y2) {
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

bool check(ld x) {
    ld prev = 0;
    
    forr(i, 1, n+1) {
        auto p = vec[i];

        if(prev <= p.f && dist(p.f, p.s, prev, 0) > x) {
            continue;
        }
        ld v = sqrt(x*x - p.s * p.s) + p.f;
        
        prev = max(prev, v);
    }
    return prev >= l;
    
}

int main() {
    // usaco();

    
    scd(n);
    sclld(l);

    vec = vector<pair<lli, lli>>(n+1);

    forr(i, 1, n+1) {
        sclld(vec[i].f);
        sclld(vec[i].s);
    }

    ld lo = 0;
    ld hi = 4e9;

    while(hi - lo >= 1e-4) {
        ld mid = (lo + hi)/2;
        if(check(mid)) {
            hi = mid;
        }
        else lo = mid;
    }

    cout << fixed << setprecision(4) << lo << "\n";

}

Compilation message

mobile.cpp: In function 'void usaco()':
mobile.cpp:37:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     freopen("input.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp: In function 'int main()':
mobile.cpp:5:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define scd(t) scanf("%d", &t)
      |                ~~~~~^~~~~~~~~~
mobile.cpp:70:5: note: in expansion of macro 'scd'
   70 |     scd(n);
      |     ^~~
mobile.cpp:7:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
mobile.cpp:71:5: note: in expansion of macro 'sclld'
   71 |     sclld(l);
      |     ^~~~~
mobile.cpp:7:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
mobile.cpp:76:9: note: in expansion of macro 'sclld'
   76 |         sclld(vec[i].f);
      |         ^~~~~
mobile.cpp:7:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 | #define sclld(t) scanf("%lld", &t)
      |                  ~~~~~^~~~~~~~~~~~
mobile.cpp:77:9: note: in expansion of macro 'sclld'
   77 |         sclld(vec[i].s);
      |         ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 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 2 ms 344 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 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 344 KB Output is correct
3 Correct 3 ms 500 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 516 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 1372 KB Output is correct
2 Correct 29 ms 1624 KB Output is correct
3 Correct 22 ms 1880 KB Output is correct
4 Correct 50 ms 2640 KB Output is correct
5 Correct 28 ms 1620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 1640 KB Output is correct
2 Correct 47 ms 1368 KB Output is correct
3 Correct 54 ms 1628 KB Output is correct
4 Correct 54 ms 2652 KB Output is correct
5 Correct 67 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1628 KB Output is correct
2 Correct 26 ms 1708 KB Output is correct
3 Correct 26 ms 2704 KB Output is correct
4 Correct 82 ms 3924 KB Output is correct
5 Correct 56 ms 2740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1880 KB Output is correct
2 Correct 32 ms 3272 KB Output is correct
3 Correct 31 ms 3020 KB Output is correct
4 Correct 82 ms 3932 KB Output is correct
5 Correct 66 ms 3160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1880 KB Output is correct
2 Correct 32 ms 3416 KB Output is correct
3 Correct 31 ms 2908 KB Output is correct
4 Correct 77 ms 3924 KB Output is correct
5 Correct 65 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 8028 KB Output is correct
2 Correct 164 ms 15980 KB Output is correct
3 Correct 158 ms 15488 KB Output is correct
4 Correct 390 ms 17720 KB Output is correct
5 Correct 345 ms 14932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 8028 KB Output is correct
2 Correct 309 ms 14864 KB Output is correct
3 Correct 184 ms 13904 KB Output is correct
4 Correct 407 ms 17748 KB Output is correct
5 Correct 352 ms 15804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 184 ms 9820 KB Output is correct
2 Correct 190 ms 19108 KB Output is correct
3 Correct 201 ms 18260 KB Output is correct
4 Correct 517 ms 21848 KB Output is correct
5 Correct 384 ms 17740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 186 ms 9820 KB Output is correct
2 Correct 369 ms 17748 KB Output is correct
3 Correct 187 ms 16484 KB Output is correct
4 Correct 457 ms 21324 KB Output is correct
5 Correct 431 ms 18904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 212 ms 11356 KB Output is correct
2 Correct 228 ms 22240 KB Output is correct
3 Correct 216 ms 21552 KB Output is correct
4 Correct 562 ms 24936 KB Output is correct
5 Correct 488 ms 20424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 11384 KB Output is correct
2 Correct 422 ms 20560 KB Output is correct
3 Correct 217 ms 19576 KB Output is correct
4 Correct 597 ms 24780 KB Output is correct
5 Correct 497 ms 21500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 253 ms 12948 KB Output is correct
2 Correct 248 ms 25368 KB Output is correct
3 Correct 252 ms 24400 KB Output is correct
4 Correct 696 ms 28556 KB Output is correct
5 Correct 546 ms 24308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 243 ms 12948 KB Output is correct
2 Correct 482 ms 23452 KB Output is correct
3 Correct 240 ms 22476 KB Output is correct
4 Correct 648 ms 28244 KB Output is correct
5 Correct 559 ms 24548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 311 ms 15960 KB Output is correct
2 Correct 316 ms 31428 KB Output is correct
3 Correct 323 ms 30800 KB Output is correct
4 Correct 849 ms 35404 KB Output is correct
5 Correct 692 ms 29808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 298 ms 15960 KB Output is correct
2 Correct 637 ms 29308 KB Output is correct
3 Correct 298 ms 28368 KB Output is correct
4 Correct 775 ms 35408 KB Output is correct
5 Correct 815 ms 30804 KB Output is correct