Submission #1225585

#TimeUsernameProblemLanguageResultExecution timeMemory
1225585jakeob77Balloons (CEOI11_bal)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ins insert
//cout<<fixed<<setprecision(3); 3 decimalke brez fixed pa 3 zanesljiva mesta
const int MAXN=1e6+3;
const long long linf=1e18;
const int inf=1e9;
const int mod=998244353;;


void solve(){
    int n;cin>>n;
    stack<pair<int,long double>>last;vector<long double>radij;
    for(int i=0;i<n;i++){
        long double x,r;cin>>x>>r;
        auto calc=[](pair<long double,long double>par,long double temp)->long double{
            return (par.first-temp)*(par.first-temp)/(4*par.second);
        };
        long double max_r=r;
        while(!last.empty()){
            pair<long double,long double>l=last.top();
            long double last_max_r=calc(l,x);
            max_r=min(max_r,last_max_r);
            if(max_r>=l.second){
                last.pop();
                continue;
            }
            else break;
        }
        last.push({x,max_r,r});
        radij.pb(max_r);
    }
    
    
    for(auto el:radij){cout<<fixed<<setprecision(4)<<el<<endl;}
}  
int main(){
    std::ios::sync_with_stdio(false);
	std::cin.tie(NULL); 
    int t=1;
    while(t--) solve();
    
}

Compilation message (stderr)

bal.cpp: In function 'void solve()':
bal.cpp:32:18: error: no matching function for call to 'std::stack<std::pair<int, long double> >::push(<brace-enclosed initializer list>)'
   32 |         last.push({x,max_r,r});
      |         ~~~~~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/11/stack:61,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:89,
                 from bal.cpp:1:
/usr/include/c++/11/bits/stl_stack.h:239:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<int, long double>; _Sequence = std::deque<std::pair<int, long double>, std::allocator<std::pair<int, long double> > >; std::stack<_Tp, _Sequence>::value_type = std::pair<int, long double>]'
  239 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_stack.h:239:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, long double>&'}
  239 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_stack.h:244:7: note: candidate: 'void std::stack<_Tp, _Sequence>::push(std::stack<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<int, long double>; _Sequence = std::deque<std::pair<int, long double>, std::allocator<std::pair<int, long double> > >; std::stack<_Tp, _Sequence>::value_type = std::pair<int, long double>]'
  244 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/11/bits/stl_stack.h:244:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::stack<std::pair<int, long double> >::value_type&&' {aka 'std::pair<int, long double>&&'}
  244 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~