# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1108145 |
2024-11-03T03:16:23 Z |
akamizane |
Balloons (CEOI11_bal) |
C++17 |
|
124 ms |
7152 KB |
#include<bits/stdc++.h>
using namespace std;
#define debug(...) 40
using ll = long long;
using pii = pair<int,int>;
using db = double;
#define el cout << '\n'
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T1, class T2>bool chmax(T1 &a, T2 b){return a < b ? a = b, 1 : 0;}
template <class T1, class T2>bool chmin(T1 &a, T2 b){return a > b ? a = b, 1 : 0;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 2e5 + 5;
const ll mod = 1e9 + 7;
db calc(pair<db, db> b, db x){
return (b.fi - x) * (b.fi - x) / (4 * b.se);
}
void solve(){
int n;
cin >> n;
stack<pair<db, db>> s;
vector<db> val(n);
for (int i = 0; i < n; i++){
double x, r;
cin >> x >> r;
double mi = r;
while(s.size()){
auto [x1, y1] = s.top();
db val = calc({x1, y1}, x);
chmin(mi, val);
if (mi >= y1) s.pop();
else break;
}
s.push({x, mi});
val[i] = mi;
}
cout << setprecision(3) << fixed;
for (auto v : val) cout << v << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int tests = 1;
// cin >> tests;
for (int _ = 1; _ <= tests; _++){
cerr << "- Case #" << _ << ": \n";
solve();
el;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
10 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
2 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
505 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
336 KB |
2000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
644 KB |
20000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1352 KB |
50000 numbers |
2 |
Correct |
29 ms |
1104 KB |
49912 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
2120 KB |
100000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
83 ms |
2564 KB |
115362 numbers |
2 |
Correct |
73 ms |
4472 KB |
119971 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
3056 KB |
154271 numbers |
2 |
Correct |
115 ms |
6996 KB |
200000 numbers |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
124 ms |
3400 KB |
200000 numbers |
2 |
Correct |
118 ms |
7152 KB |
199945 numbers |