# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
474253 | codesauce | Balloons (CEOI11_bal) | C++17 | 4 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpi = vector<pair<int, int>>;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define all(x) begin(x), end(x)
const int MAX = 2e5 + 5;
const long long INF = 1e18;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.in", "r", stdin);
freopen("output.out", "w", stdout);
#endif
/*When adding a balloon to a stack, we can remove all
* the ballons which are smaller than this balloon.
* Every time you pop the top element of the stack, check
* if you can lower the size of the current balloon.
* Finally when the preceding balloon is larger than the current
* balloon, again check if you can further lower the size of
* the balloon being added*/
int n; cin >> n;
double long x[n], r[n];
FOR(i, 0, n) cin >> x[i] >> r[i];
stack<pair<double long, double long>> st;
double long ans[n];
FOR(i, 0, n){
double long r1 = r[i];
while(!st.empty() && r1 >= st.top().f){
double long p = (x[i] - st.top().s)*(x[i] - st.top().s);
double long r2 = p/(4*(st.top().f));
r1 = min(r1, r2);
if(r1 < st.top().f) break;
st.pop();
}
if(!st.empty()){
double long p = (x[i] - st.top().s)*(x[i] - st.top().s);
double long r2 = p/(4*(st.top().f));
r1 = min(r1, r2);
}
st.push({r1, x[i]});
ans[i] = r1;
}
cout << fixed << setprecision(3);
FOR(i, 0, n) cout << ans[i] << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |