답안 #305207

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305207 2020-09-22T17:43:12 Z oleksg Mobile (BOI12_mobile) C++14
0 / 100
1000 ms 48176 KB
#include <fstream>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include<bits/stdc++.h>
#include <vector>
using namespace std;

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

bool ok(double cur){
    vector<pair<double, double>> segs;
    for (long long x = 0; x < points.size(); x++){
        double curx = points[x].first;
        double cury = abs(points[x].second);
        double xintervals = sqrt(pow(cur, 2) - pow(cury, 2));
        double minx = max((double)0, curx - xintervals);
        double maxx = min((double)l, curx + xintervals);
        segs.push_back(make_pair(minx, maxx));
    }
    sort(segs.begin(), segs.end());
    double curx = 0;
    for (long long x = 0; x < segs.size(); x++){
        if (segs[x].second > curx){
            if (segs[x].first <= curx){
                curx = segs[x].second;
            }
            else{
                return false;
            }
        }
    }
    if (curx < l){
        return false;
    }
    return true;
}
int main(){
    long long 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;
    double ma = 10000000000;
    while(ma - mi > 0.00001){
        double cur = (mi + ma) / 2.0;
        if (ok(cur)){
            ma = cur;
        }
        else{
            mi = cur + 0.00001;
        }
    }
    cout << setprecision(20) << ma << "\n";
}

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<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for (long long x = 0; x < points.size(); x++){
      |                           ~~^~~~~~~~~~~~~~~
mobile.cpp:25: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]
   25 |     for (long long x = 0; x < segs.size(); x++){
      |                           ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 328 ms 5136 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 334 ms 5020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 356 ms 5284 KB Output is correct
2 Correct 414 ms 5136 KB Output is correct
3 Incorrect 354 ms 5268 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 443 ms 5608 KB Output is correct
2 Correct 508 ms 7012 KB Output is correct
3 Incorrect 405 ms 6644 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 5680 KB Output is correct
2 Correct 507 ms 5652 KB Output is correct
3 Incorrect 400 ms 5616 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 24368 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1099 ms 24376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 35948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 35796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 38788 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1087 ms 35900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1068 ms 41972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1039 ms 16904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 48176 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 16848 KB Time limit exceeded
2 Halted 0 ms 0 KB -