Submission #310517

# Submission time Handle Problem Language Result Execution time Memory
310517 2020-10-07T08:37:28 Z vishnu_sujith Mobile (BOI12_mobile) C++17
100 / 100
793 ms 18168 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG
#define LOG(...) cerr << "[" << #__VA_ARGS__ << "]: " << repr(__VA_ARGS__) << endl;
#define MSG(args) cerr << args << "\n";
#define debug(x) x
#else
#define LOG(...)
#define MSG(args)
#define debug(x)
#endif

#define vi vector<int>
#define ii pair<int, int>
#define vii vector< ii >
#define vvi vector< vi >
#define mp make_pair
#define pb push_back
#define sz(x) (int)((x).size())
#define ms(x, v) memset((x), v, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define REP(x, n) for(int x = 0; x < n; x++)
#define REPV(x, v, n) for(int x = v; x < n; x++)
#define REVE(x, n) for(int x = n; x >= 0; x--)

typedef long long ll;

int N, L;
double posX[1000010], posY[1000010];

bool can(double d)
{
    double cover = 0.0;
    REP(i, N)
    {
	double dist = sqrt(d * d - posY[i] * posY[i]);
	double lft = posX[i] - dist, rgt = posX[i] + dist;
	if(lft <= cover)
	    cover = max(cover, rgt);
    }
    return cover >= L;
}

int main()
{
    scanf("%d%d", &N, &L);
    REP(i, N)
	scanf("%lf%lf", &posX[i], &posY[i]);
    double lo = 1.0, hi = 9e8;
    while(hi - lo > 1e-3)
    {
	double mid = (lo + hi) / 2.0;
	if(can(mid))
	    hi = mid;
	else
	    lo = mid;
    }
    printf("%.7lf\n", lo);
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |     scanf("%d%d", &N, &L);
      |     ~~~~~^~~~~~~~~~~~~~~~
mobile.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   50 |  scanf("%lf%lf", &posX[i], &posY[i]);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 416 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 1544 KB Output is correct
2 Correct 43 ms 1536 KB Output is correct
3 Correct 31 ms 1152 KB Output is correct
4 Correct 54 ms 1548 KB Output is correct
5 Correct 37 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 1536 KB Output is correct
2 Correct 46 ms 1480 KB Output is correct
3 Correct 58 ms 1656 KB Output is correct
4 Correct 59 ms 1528 KB Output is correct
5 Correct 65 ms 1676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 1656 KB Output is correct
2 Correct 46 ms 1664 KB Output is correct
3 Correct 54 ms 1656 KB Output is correct
4 Correct 80 ms 1912 KB Output is correct
5 Correct 57 ms 1656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 1912 KB Output is correct
2 Correct 61 ms 1912 KB Output is correct
3 Correct 56 ms 1912 KB Output is correct
4 Correct 79 ms 1912 KB Output is correct
5 Correct 67 ms 1916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 1912 KB Output is correct
2 Correct 61 ms 1912 KB Output is correct
3 Correct 58 ms 2040 KB Output is correct
4 Correct 79 ms 1912 KB Output is correct
5 Correct 68 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 245 ms 8312 KB Output is correct
2 Correct 282 ms 8312 KB Output is correct
3 Correct 280 ms 8184 KB Output is correct
4 Correct 392 ms 8312 KB Output is correct
5 Correct 347 ms 8188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 289 ms 8232 KB Output is correct
2 Correct 365 ms 8188 KB Output is correct
3 Correct 282 ms 8184 KB Output is correct
4 Correct 386 ms 8184 KB Output is correct
5 Correct 370 ms 8440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 303 ms 9720 KB Output is correct
2 Correct 338 ms 9940 KB Output is correct
3 Correct 332 ms 9720 KB Output is correct
4 Correct 502 ms 9956 KB Output is correct
5 Correct 409 ms 9848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 341 ms 9980 KB Output is correct
2 Correct 436 ms 9848 KB Output is correct
3 Correct 350 ms 9748 KB Output is correct
4 Correct 473 ms 9720 KB Output is correct
5 Correct 420 ms 9664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 353 ms 11384 KB Output is correct
2 Correct 392 ms 11256 KB Output is correct
3 Correct 392 ms 11384 KB Output is correct
4 Correct 547 ms 11256 KB Output is correct
5 Correct 475 ms 11512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 399 ms 11384 KB Output is correct
2 Correct 503 ms 11384 KB Output is correct
3 Correct 405 ms 11512 KB Output is correct
4 Correct 544 ms 11384 KB Output is correct
5 Correct 500 ms 11384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 393 ms 12792 KB Output is correct
2 Correct 451 ms 12928 KB Output is correct
3 Correct 448 ms 13048 KB Output is correct
4 Correct 626 ms 13048 KB Output is correct
5 Correct 560 ms 12920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 461 ms 12892 KB Output is correct
2 Correct 572 ms 12988 KB Output is correct
3 Correct 470 ms 12792 KB Output is correct
4 Correct 621 ms 12940 KB Output is correct
5 Correct 573 ms 12924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 515 ms 15992 KB Output is correct
2 Correct 559 ms 15992 KB Output is correct
3 Correct 564 ms 16208 KB Output is correct
4 Correct 785 ms 16248 KB Output is correct
5 Correct 691 ms 18168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 570 ms 15992 KB Output is correct
2 Correct 713 ms 16120 KB Output is correct
3 Correct 589 ms 16120 KB Output is correct
4 Correct 793 ms 16120 KB Output is correct
5 Correct 722 ms 18168 KB Output is correct