Submission #706391

#TimeUsernameProblemLanguageResultExecution timeMemory
706391vjudge1Balloons (CEOI11_bal)C++11
100 / 100
1391 ms2140 KiB
#include<iostream>
#include<vector>
using namespace std;
vector<pair<long double,long double> > curr;
int n;
long double findval(int pos, long double x) {
    return (curr[pos].first-x)*(curr[pos].first-x)/4.0/curr[pos].second;
}
int main () {
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        long double x,rad;
        int minp = curr.size();
        scanf("%Lf%Lf",&x,&rad);
        for(int j = 0; j < curr.size(); j++) {
            if(findval(j,x) < rad) {
                minp = j;
                rad = findval(j,x);
            }
        }
        int tmp = curr.size();
        for(int j = minp+1; j < tmp; j++) {
            curr.pop_back();
        }
        while(curr.size() > 0 && rad+((long double) 1e-18) > curr.back().second) {
            curr.pop_back();
        }
        curr.push_back(make_pair(x,rad));
        printf("%.3Lf\n",rad);
    }
    return 0;
}

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:15:26: 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]
   15 |         for(int j = 0; j < curr.size(); j++) {
      |                        ~~^~~~~~~~~~~~~
bal.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
bal.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf("%Lf%Lf",&x,&rad);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
#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...