Submission #671015

#TimeUsernameProblemLanguageResultExecution timeMemory
671015a_aguiloBalloons (CEOI11_bal)C++14
0 / 100
2033 ms37480 KiB
#include<bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vpii; int n; long double Radius(int d, long double r){ return (long double)(d)*((long double) d/(4*r)); } void print(vector<pair<int, long double>>& V){ cout << V[0].first << " " << V[0].second; for(int i = 1; i < V.size(); ++i) cout << " | "<< V[i].first << " " << V[i].second; cout << endl; } int main(){ cin >> n; int lastIdx; int position[n]; long double radius[n]; vector<pair<int, long double>> MyStack; cin >> position[0] >> radius[0]; MyStack.push_back({position[0], radius[0]}); for(int i = 1; i < n; ++i){ cin >> position[i] >> radius[i]; while((MyStack.size() > 1)){ lastIdx = MyStack.size()-1; long double LastRad = Radius(position[i] - MyStack[lastIdx].first, MyStack[lastIdx].second); long double PrevRad = Radius(position[i] - MyStack[lastIdx-1].first, MyStack[lastIdx-1].second); if(LastRad > min(radius[i], PrevRad)) MyStack.pop_back(); else break; } lastIdx = MyStack.size()-1; long double finalRad = Radius(position[i] - MyStack[lastIdx].first, MyStack[lastIdx].second); radius[i] = min(radius[i], finalRad); MyStack.push_back({position[i], radius[i]}); cout << i << endl; print(MyStack); } cout << endl; for(int i = 0; i < n; ++i) cout << fixed << radius[i] << endl; return 0; }

Compilation message (stderr)

bal.cpp: In function 'void print(std::vector<std::pair<int, long double> >&)':
bal.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int i = 1; i < V.size(); ++i) cout << " | "<< V[i].first << " " << V[i].second;
      |                    ~~^~~~~~~~~~
#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...