# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
446155 |
2021-07-21T06:51:08 Z |
abitpal |
Balloons (CEOI11_bal) |
C++14 |
|
2000 ms |
5608 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();
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 |
1 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 |
2 ms |
204 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
400 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
741 ms |
1364 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2054 ms |
2300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2085 ms |
3432 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2080 ms |
3680 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2080 ms |
5164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2085 ms |
5608 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |