# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
446154 |
2021-07-21T06:49:35 Z |
abitpal |
Balloons (CEOI11_bal) |
C++14 |
|
2000 ms |
5844 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]
float calc(pair<float, float> a, float b){
float dif = pow(abs(a.first - b), 2);
return (dif/(4 * a.second));
}
int main(){
int n; cin >> n;
pair<float,float> ar[n];
for (int i = 0; i < n; i++){
cin >> ar[i].first >> ar[i].second;
}
float ans[n];
ans[0] = ar[0].second;
vector<pair<float, float>> v;
v.push_back({ar[0].first, ar[0].second});
for (int i = 1; i < n; i++){
float cur = ar[i].second;
float 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 |
Incorrect |
1 ms |
204 KB |
1st numbers differ - expected: '247294217.0000000000', found: '247294224.0000000000', error = '7.0000000000' |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
308 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
750 ms |
1300 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2087 ms |
2184 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2084 ms |
3532 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2077 ms |
4116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2077 ms |
5176 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2087 ms |
5844 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |