Submission #1217435

#TimeUsernameProblemLanguageResultExecution timeMemory
1217435KALARRYBalloons (CEOI11_bal)C++20
10 / 100
93 ms2628 KiB
//chockolateman

#include<bits/stdc++.h>

using namespace std;

int N;

long double give_R(long long x,long long a,long double b)
{
    long double R = (x-a)*(x-a)/(4*b);
    return R;
}

int main()
{
    scanf("%d",&N);
    stack<pair<int,int>> ord;
    for(long long x,r,i = 1 ; i <= N ; i++)
    {
        scanf("%lld%lld",&x,&r);
        long double R = r;
        while(!ord.empty())
        {
            long long a = ord.top().first;
            long double b = ord.top().second;
            long double cur = give_R(x,a,b);
            R = min(R,cur);
            if(R > b)
                ord.pop();
            else
                break;
        }
        printf("%.7Lf\n",R);
        ord.push({x,R});
    }
    return 0;
}

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
bal.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%lld%lld",&x,&r);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...