Submission #848420

# Submission time Handle Problem Language Result Execution time Memory
848420 2023-09-12T15:03:36 Z Essa2006 Balloons (CEOI11_bal) C++14
40 / 100
2000 ms 2792 KB
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
const double eps=0.000001;
double diss(double x, double y, double x2, double y2){
    return sqrt(abs(x-x2)*abs(x-x2)+abs(y-y2)*abs(y-y2));
}
 
bool intersect(double firy, double dis, double secy){
    double firx=0;
    double secx=dis;
    double r1=firy, r2=secy;
    return (bool)(diss( firx, firy, secx, secy)-r1-r2<eps);
}
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin>>n;
    vector<int>A(n);
    vector<double>Ans(n);
    for(int i=0;i<n;i++){
        int x, r;
        cin>>x>>r;
        A[i]=x;
        double lim=r, mx=0;
        for(int j=i-1;j>=0;j--){
            double l=0, r=1e9, res;
            int cnt=50;
            while(cnt--){
                double md=(l+r)*0.5;
                if(intersect(Ans[j], x-A[j], md))
                    r=md-0.1;
                else
                    res=md, l=md+0.1;
            }
            if(Ans[j]<mx)
                continue;
            mx=Ans[j];
            lim=min(lim, res);
        }
        Ans[i]=lim;
        cout<<endl;
    }
    cout<<fixed<<setprecision(3);
    for(int i=0;i<n;i++){
        cout<<Ans[i]<<endl;
    }
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:130:15: warning: 'lim' may be used uninitialized in this function [-Wmaybe-uninitialized]
  130 |         Ans[i]=lim;
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 91 ms 440 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 1391 ms 456 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2066 ms 692 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2044 ms 1112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2028 ms 1624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2025 ms 1796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2101 ms 2392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2057 ms 2792 KB Time limit exceeded
2 Halted 0 ms 0 KB -