Submission #305306

# Submission time Handle Problem Language Result Execution time Memory
305306 2020-09-22T23:05:15 Z oleksg Mobile (BOI12_mobile) C++14
50 / 100
1000 ms 16912 KB
#include <fstream>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include<bits/stdc++.h>
#include <vector>
using namespace std;

double n, l;
vector<pair<double, double>> points;

bool ok(double cur){
    double curmaxx = 0;
    for (long long x = 0; x < points.size(); ++x){
        double curx = points[x].first;
        double cury = abs(points[x].second);
        if (cur >= cury){
            double xintervals = sqrt(cur * cur - cury * cury);
            double minx = curx - xintervals;
            double maxx = curx + xintervals;
            if (minx <= l && maxx >= 0 && cur >= cury){
                if (minx <= curmaxx){
                    curmaxx = max(curmaxx, maxx);
                    if ((curmaxx) >= l){
                        return true;
                    }
                }
            }
        }
    }
    return curmaxx >= l;
}
int main(){
    double one, two;
    cin >> n >> l;
    for (int x = 0; x < n; ++x){
        cin >> one >> two;
        points.push_back(make_pair(one, two));
    }
    double mi = 0.0;
    double ma = 10000000000;
    //cout << ok(658);
    while(ma > mi + 0.0005){
        double cur = (mi + ma) / 2.0;
        if (ok(cur)){
            ma = cur;
        }
        else{
            mi = cur;
        }
    }
    printf("%.15g", ma);
}

Compilation message

mobile.cpp: In function 'bool ok(double)':
mobile.cpp:15:29: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (long long x = 0; x < points.size(); ++x){
      |                           ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 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 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 512 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 7 ms 512 KB Output is correct
2 Correct 9 ms 512 KB Output is correct
3 Correct 8 ms 500 KB Output is correct
4 Correct 11 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 512 KB Output is correct
2 Correct 11 ms 512 KB Output is correct
3 Correct 9 ms 512 KB Output is correct
4 Correct 13 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 512 KB Output is correct
2 Correct 9 ms 512 KB Output is correct
3 Correct 9 ms 512 KB Output is correct
4 Correct 13 ms 512 KB Output is correct
5 Correct 7 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 144 ms 2536 KB Output is correct
2 Correct 163 ms 2572 KB Output is correct
3 Correct 95 ms 1520 KB Output is correct
4 Correct 158 ms 2540 KB Output is correct
5 Correct 72 ms 1520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 134 ms 2540 KB Output is correct
2 Correct 128 ms 2516 KB Output is correct
3 Correct 144 ms 2540 KB Output is correct
4 Correct 167 ms 2540 KB Output is correct
5 Correct 194 ms 2540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 2540 KB Output is correct
2 Correct 184 ms 2484 KB Output is correct
3 Correct 160 ms 2540 KB Output is correct
4 Correct 235 ms 2488 KB Output is correct
5 Correct 158 ms 2536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 226 ms 2544 KB Output is correct
2 Correct 227 ms 2556 KB Output is correct
3 Correct 160 ms 2540 KB Output is correct
4 Correct 235 ms 2500 KB Output is correct
5 Correct 169 ms 2536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 234 ms 2540 KB Output is correct
2 Correct 184 ms 2540 KB Output is correct
3 Correct 171 ms 2536 KB Output is correct
4 Correct 244 ms 2540 KB Output is correct
5 Correct 174 ms 2464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 881 ms 8668 KB Output is correct
2 Execution timed out 1085 ms 8644 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 8708 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 16824 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 8628 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 16836 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 16912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 16868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 16816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 16816 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 16824 KB Time limit exceeded
2 Halted 0 ms 0 KB -