# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
446156 |
2021-07-21T06:55:55 Z |
abitpal |
Balloons (CEOI11_bal) |
C++14 |
|
1911 ms |
10244 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9 + 7;
int di[] = {1, 0, -1, 0}, dj[] = {0, 1, 0, -1};
unsigned ll gcd(unsigned ll a ,unsigned ll b){
if(b==0) return a;
a%=b;
return gcd(b,a);
}
unsigned ll lcm(unsigned ll a ,unsigned ll b){
return (a /(gcd(a, b))) * b;
}
ll binpow(ll a, ll b, ll m){
a %= m;
ll ans = 1;
while (b > 0){
if (b%2){
ans = ans * a % m;
}
a = a * a % m;
b /= 2;
}
return ans % m;
}
int e[2000];
int get(int x) {return e[x] < 0 ? x : e[x] = get(e[x]); }
int size(int x) {return -e[get(x)]; }
int unite(int a, int b){
if (get(a) == get(b)) return 0;
a = get(a); b = get(b);
if (e[a] > e[b]) swap(a, b);
e[a] += e[b]; e[b] = a;
return 1;
}
// dp[i] - number of ways to produce the sum of i, using the values on a dice
// dp[i] += dp[i-1] + dp[i-2] .. + dp[i-6]
double calc(pair<double, double> a, double b){
double dif = pow(abs(a.first - b), 2);
return (dif/(4 * a.second));
}
int main(){
int n; cin >> n;
pair<double,double> ar[n];
for (int i = 0; i < n; i++){
cin >> ar[i].first >> ar[i].second;
}
double ans[n];
ans[0] = ar[0].second;
vector<pair<double, double>> v;
v.push_back({ar[0].first, ar[0].second});
for (int i = 1; i < n; i++){
double cur = ar[i].second;
double x = ar[i].first;
for (auto i : v){
cur = min(cur, calc(i, x));
}
if (cur != ar[i].second)
while (!v.empty() && calc(v.back(), x) != cur) v.pop_back();
while (!v.empty() && v.back().second <= cur) v.pop_back();
v.push_back({x, cur});
ans[i] = cur;
}
for (int i = 0; i < n; i++){
cout << fixed;
cout << setprecision(3);
cout << ans[i] << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
204 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
332 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
856 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
727 ms |
2108 KB |
50000 numbers |
2 |
Correct |
433 ms |
2716 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1200 ms |
3812 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1679 ms |
4276 KB |
115362 numbers |
2 |
Correct |
1058 ms |
6188 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1911 ms |
5588 KB |
154271 numbers |
2 |
Correct |
1713 ms |
10084 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1119 ms |
6640 KB |
200000 numbers |
2 |
Correct |
1760 ms |
10244 KB |
199945 numbers |