답안 #312573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
312573 2020-10-13T17:54:14 Z fatemetmhr Balloons (CEOI11_bal) C++17
100 / 100
235 ms 10748 KB
#include<bits/stdc++.h>
#define sanastd using namespace std
sanastd;
 
const int MAXN = 1000 * 1000 + 10;
const long long INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
 
long long n, r[MAXN], x[MAXN];
long double ans[MAXN];
stack <int> balloon;

int main ()
{
    cout<<fixed<<setprecision(15);
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
    cin >> n >> x[0] >> r[0];
    balloon.push(0);
    ans[0] = r[0];
    cout << r[0] << endl;
    for(int i = 1; i < n; i++){
        cin >> x[i] >> r[i];
        ans[i] = r[i];
        while(!balloon.empty() and ans[balloon.top()] <= ans[i]){
            long double d = (x[i] - x[balloon.top()]) * (x[i] - x[balloon.top()]) / ( ans[balloon.top()] * 4.0);
            ans[i] = min(ans[i], d);
            if(ans[i] >= ans[balloon.top()]) balloon.pop();
        }
        if(!balloon.empty()){
            long double d = (x[i] - x[balloon.top()]) * (x[i] - x[balloon.top()]) / (ans[balloon.top()] * 4.0);
            ans[i] = min(ans[i], d);
        }
        balloon.push(i);
        cout << ans[i] << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB 505 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB 2000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1408 KB 20000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3064 KB 50000 numbers
2 Correct 60 ms 2808 KB 49912 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 128 ms 5668 KB 100000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 6548 KB 115362 numbers
2 Correct 118 ms 6264 KB 119971 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 199 ms 8408 KB 154271 numbers
2 Correct 193 ms 10364 KB 200000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 235 ms 10748 KB 200000 numbers
2 Correct 192 ms 10232 KB 199945 numbers