Submission #844278

# Submission time Handle Problem Language Result Execution time Memory
844278 2023-09-05T11:58:58 Z AsandeiStefan Balloons (CEOI11_bal) C++17
100 / 100
487 ms 10836 KB
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;

const int M = 200005;
int n, top;
double x[M], r[M], q[M];

double Cal(int i, int j) {
  return (x[i] - x[j]) * (x[i] - x[j]) / (4 * r[j]);
}

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

    for(int i = 1; i <= n; i++) {
        while(top) {
            int j = q[top];
            r[i] = min(r[i], Cal(i,j));
            if(r[i] >= r[j]) top--;
            else break;
        }
        q[++top] = i;
    }
    for(int i = 1; i <= n; i++) cout << fixed << setprecision(5) << r[i] << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 4444 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 48 ms 4944 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 4988 KB 50000 numbers
2 Correct 117 ms 5712 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 241 ms 5620 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 292 ms 5820 KB 115362 numbers
2 Correct 283 ms 7760 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 393 ms 6224 KB 154271 numbers
2 Correct 467 ms 10320 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 487 ms 6992 KB 200000 numbers
2 Correct 471 ms 10836 KB 199945 numbers