Submission #1116622

# Submission time Handle Problem Language Result Execution time Memory
1116622 2024-11-22T02:35:12 Z pemguimn Balloons (CEOI11_bal) C++17
50 / 100
2000 ms 4944 KB
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 2e5 + 5;
 
int n, x[N], r[N];
 
long double ans[N];
 
long double calc(int i, int j){
    double x1 = x[i], y1 = ans[i];
    double x2 = x[j];
    return (x1 * x1 + x2 * x2 - 2 * x1 * x2 ) / (4 * y1);
}
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  
    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++){
        long double reach = r[i];
        for(int j = 1; j < i; j++){
          reach = min(reach, calc(j, i));
        }
        ans[i] = reach;
    }
 
 
    for(int i = 1; i <= n; i++)
        cout << setprecision(3) << fixed << ans[i] << "\n";
 
    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 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 336 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 15 ms 336 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 1645 ms 940 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2053 ms 1616 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2053 ms 2640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2040 ms 4172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2051 ms 3912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2041 ms 4944 KB Time limit exceeded
2 Halted 0 ms 0 KB -