We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0e93b09 commit 0e8106cCopy full SHA for 0e8106c
3000/3307/3307.cpp
@@ -0,0 +1,36 @@
1
+#include <bits/stdc++.h>
2
+using namespace std;
3
+
4
+int n, x[200000], i;
5
+double ans[200000];
6
7
+double square(double v){
8
+ return v*v;
9
+}
10
11
+int main() {
12
+ ios::sync_with_stdio(false); cin.tie(NULL);
13
14
+ cin>>n;
15
+ for(i=0;i<n;++i){
16
+ cin>>x[i]>>ans[i];
17
+ }
18
19
+ vector<int> st;
20
+ st.push_back(0);
21
22
+ for(i=1;i<n;++i){
23
+ while(!st.empty()){
24
+ int j = st.back();
25
+ ans[i] = min(ans[i], 0.25 * square(x[i]-x[j]) / ans[j]);
26
+ if(ans[j] < ans[i]) st.pop_back();
27
+ else break;
28
29
+ st.push_back(i);
30
31
32
+ for(i=0;i<n;++i) printf("%.4f\n", ans[i]);
33
34
+ return 0;
35
36
0 commit comments