제출 #1116641

#제출 시각아이디문제언어결과실행 시간메모리
1116641pemguimnBalloons (CEOI11_bal)C++14
0 / 100
3 ms336 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 2e6 + 5;

int n, x[N], r[N];

long double ans[N];

inline long double calc(int i, int j){
    long double x1 = x[i], y1 = ans[i];
    long double x2 = x[j];
    return (x1 * x1 + x2 * x2 - 2.0L * x1 * x2) / (4.0L * y1);
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifndef Pemgu
        #define task "BALLOONS"
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    #endif // Pemgu

    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> r[i];
        ans[i] = r[i];
    }

    stack<int> st;
    for(int i = 1; i <= n; i++){
        while(st.size()){
            ans[i] = min(ans[i], calc(st.top(), i));
            if(ans[i] < ans[st.top()]) break;
            st.pop();
        }
        if(ans[i] > 0.0L) st.push(i);
    }

    for(int i = 1; i <= n; i++)
        cout << setprecision(3) << fixed << ans[i] << "\n";

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

bal.cpp: In function 'int main()':
bal.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...