Submission #115549

# Submission time Handle Problem Language Result Execution time Memory
115549 2019-06-08T06:47:10 Z gs14004 Balloons (CEOI11_bal) C++17
100 / 100
188 ms 10488 KB
#include <cstdio>
#include <cmath>
#include <stack>
#include <algorithm>
using namespace std;
typedef long double lfloat;

int n, x[200005], l[200005];
lfloat r[200005];
stack<int> s;

long double col(int i, int j){
    return 0.25 * (x[i] - x[j]) * (x[i] - x[j]) / r[i];
}

int main(){
    scanf("%d",&n);
    for (int i=0; i<n; i++) {
        scanf("%d %d",&x[i],&l[i]);
        r[i] = l[i];
        while (!s.empty()) {
            r[i] = min(r[i],col(s.top(),i));
            if(r[s.top()] < r[i]){
                s.pop();
            }
            else break;
        }
        s.push(i);
        printf("%.3Lf\n",r[i]);
    }
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bal.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&x[i],&l[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 4 ms 512 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 16 ms 1180 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2672 KB 50000 numbers
2 Correct 31 ms 2944 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 81 ms 5168 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 188 ms 5724 KB 115362 numbers
2 Correct 72 ms 6520 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 121 ms 7544 KB 154271 numbers
2 Correct 111 ms 10488 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 152 ms 9380 KB 200000 numbers
2 Correct 110 ms 10484 KB 199945 numbers