# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
445820 |
2021-07-19T17:50:09 Z |
O_o |
Balloons (CEOI11_bal) |
C++14 |
|
223 ms |
11744 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define all(A) A.begin(),A.end()
#define allr(A) A.rbegin(),A.rend()
#define precise(i) fixed << setprecision(i)
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define err() cout<<"\n==================================\n";
#define errA(A) for(auto i:A) cout<<i<<" "; cout<<"\n";
#define err1(a) cout<<#a<<" "<<a<<"\n";
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<"\n";
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<"\n";
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<"\n";
const int logN = 20;
const int M = 1000000007;
const int INF = 1e17;
#define PI 3.14159265;
const int N = 200005;
#define Pii pair<int,int>
#define Vi vector<int>
#define Vpii vector<Pii>
#define PQ priority_queue<int>
void setIO(string d_name = "") {
ios_base::sync_with_stdio(0); cin.tie(0);
if(sz(d_name)){
freopen((d_name+".in").c_str(), "r", stdin);
freopen((d_name+".out").c_str(), "w", stdout);
}
}
struct Node
{
int x;
int num;
int den;
Node(){}
Node(int a, int b, int c):x(a), num(b), den(c){}
};
int32_t main()
{
setIO();
int n;
cin>>n;
Vpii b(n);
rep(i,0,n)
{
cin>>b[i].fi>>b[i].se;
}
stack<Node> s;
vector<ld> ans(n, 1e10);
rep(i,0,n)
{
bool flag= true;
while(!s.empty())
{
Node p= s.top();
if(((p.x-b[i].fi)*(p.x-b[i].fi)*(p.den)) <= 4*(p.num)*(b[i].se))
{
int g= __gcd(((p.x-b[i].fi)*(p.x-b[i].fi)*(p.den)), 4*(p.num));
ans[i]= min(ans[i], ((ld)(((p.x-b[i].fi)*(p.x-b[i].fi)*(p.den))))/((ld)(4*(p.num))));
flag= false;
if((p.num)*(4*(p.num)/g) <= (((p.x-b[i].fi)*(p.x-b[i].fi)*(p.den))/g)*(p.den))
{
s.pop();
continue;
}
else
{
s.push(Node(b[i].fi, ((p.x-b[i].fi)*(p.x-b[i].fi)*(p.den))/g, 4*(p.num)/g));
break;
}
}
else if((b[i].se)*(p.den) >= (p.num))
{
s.pop();
continue;
}
else
{
break;
}
}
if(flag)
{
s.push(Node(b[i].fi, b[i].se, 1));
ans[i]= (ld)(b[i].se);
}
}
rep(i,0,n)
{
cout<<precise(7)<<ans[i]<<"\n";
}
return 0;
}
Compilation message
bal.cpp: In function 'void setIO(std::string)':
bal.cpp:40:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | freopen((d_name+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:41:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
41 | freopen((d_name+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
7th numbers differ - expected: '0.0010000000', found: '9.0000000000', error = '8.9990000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
12th numbers differ - expected: '110.0020000000', found: '117.0000000000', error = '6.9980000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
1388 KB |
6th numbers differ - expected: '208.0010000000', found: '213.0000000000', error = '4.9990000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
3184 KB |
8th numbers differ - expected: '15392.0000000000', found: '15396.0000000000', error = '4.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
118 ms |
6136 KB |
5th numbers differ - expected: '7934.0000000000', found: '15.3676849000', error = '7918.6323151000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
135 ms |
7040 KB |
8th numbers differ - expected: '5051.0000000000', found: '631.5247879000', error = '4419.4752121000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
199 ms |
9448 KB |
6th numbers differ - expected: '1869.0000000000', found: '-49.2379767000', error = '1918.2379767000' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
223 ms |
11744 KB |
5th numbers differ - expected: '2958.0000000000', found: '2962.0000000000', error = '4.0000000000' |
2 |
Halted |
0 ms |
0 KB |
- |