Submission #706388

#TimeUsernameProblemLanguageResultExecution timeMemory
706388vjudge1Balloons (CEOI11_bal)C++11
20 / 100
153 ms2016 KiB
#include<iostream> #include<vector> using namespace std; const long double absdiff = 0; 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; } bool isPoss(int pos, long double x) { if(pos <= 0) return true; if(pos >= curr.size()) return false; return (findval(pos,x)+absdiff < findval(pos-1,x)); } int main () { scanf("%d",&n); for(int i = 0; i < n; i++) { long double x,rad; scanf("%Lf%Lf",&x,&rad); if(curr.size() > 0) { int l = -1, r = curr.size(); while(l+1 < r) { int mid = (l+r)/2; if(isPoss(mid,x) == true) l = mid; else r = mid; } rad = min(rad,findval(l,x)); } while(curr.size() > 0 && rad+absdiff > 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 'bool isPoss(int, long double)':
bal.cpp:12:12: 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]
   12 |     if(pos >= curr.size()) return false;
      |        ~~~~^~~~~~~~~~~~~~
bal.cpp: In function 'int main()':
bal.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
bal.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         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...