Submission #810186

#TimeUsernameProblemLanguageResultExecution timeMemory
810186darklightBalloons (CEOI11_bal)C++14
100 / 100
524 ms8608 KiB
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long double typedef long long ll; #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) int cal(pair<int,int> a,int bx) { return (a.first-bx)*(a.first-bx)/(4*a.second); } void solve(){ int n;cin>>n; vector<int> ans(n); stack<pair<int,int>> s; for(int i=0;i<n;i++){ int x,r;cin>>x>>r; int max_radius=r; while(!s.empty()){ pair<int,int> last=s.top(); int curr=cal(last,x); max_radius=min(max_radius,curr); if(max_radius>=last.second){ s.pop();continue; } else break; } s.push({x, max_radius}); ans[i]=max_radius; } cout<<fixed<<setprecision(3); for(auto &x:ans) cout<<x<<endl; } int32_t main(){ // freopen('input.txt','r',stdin); // freopen('output.txt','w',stdout); solve(); // 48-57:0-9 / 65-90:A-Z / 97-122:a-z // DECIMAL: cout<<fixed<<setprecision(8)<<ans; // PREFIX+SUFFIX: exclude a element in the array // PREFIX_SUM: binary array // DFS/BFS: states being visited again // BINARY_SEARCH: maximize the minimum possible/minimize the maximum possible return 0; }
#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...