Submission #1109878

# Submission time Handle Problem Language Result Execution time Memory
1109878 2024-11-08T01:58:53 Z ChottuF Mobile (BOI12_mobile) C++17
0 / 100
452 ms 70320 KB
#include <bits/stdc++.h>
using namespace std;

inline long double f(pair<long double,long double> a, pair<long double,long double> b){
    return ((a.first-b.first)*(a.first-b.first)) + ((a.second-b.second)*(a.second-b.second));
}

signed main(){
    long double n,l;
    cin >> n >> l;
    stack<pair<long double,long double>> s;
    for (int i = 0; i<n; i++){
        long double a,b;
        cin >> a >> b;
        if (s.empty()){
            s.push({a,b});
        }
        else{
            while (true){
                pair<long double,long double> d = s.top();
                if (d.second > b){
                    //take him out
                    s.pop();
                }
                else{
                    break;
                }
            }
            s.push({a,b});
        }
    }
    vector<pair<long double,long double>> vec;
    while (!s.empty()){
        vec.push_back(s.top());
        s.pop();
    }
    reverse(vec.begin(),vec.end());
    long double mx = 0;
    for (int i = 0; i<vec.size()-1; i++){
        auto [x1, y1] = vec[i];
        auto [x2, y2] = vec[i+1];
        long double m = (y1-y2)/(x1-x2);
        
        const long double NEGONE = -1;
        long double newm = NEGONE/m;
        long double a = (x1+x2)/2;
        long double b = (y1+y2)/2;
        long double c = b - (newm*a);
        
        //y = newm * x + c
        long double newx = -c/newm;
        mx = max(mx, f({0,newx},vec[i]));
    }
    int sz = vec.size();
    mx = max(mx, vec[0].first*vec[0].first + vec[0].second*vec[0].second);
    mx = max(mx, (vec[sz-1].first-l)*(vec[sz-1].first-l) + vec[0].second + vec[0].second);
    cout << sqrtl(mx);
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long double, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i<vec.size()-1; i++){
      |                     ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 47 ms 9612 KB Output is correct
2 Runtime error 2 ms 608 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 254 ms 39404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 318 ms 58428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 331 ms 58600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 336 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 368 ms 65768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 464 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 452 ms 70320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 592 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -