Submission #127103

# Submission time Handle Problem Language Result Execution time Memory
127103 2019-07-08T22:24:05 Z eriksuenderhauf Balloons (CEOI11_bal) C++11
100 / 100
308 ms 14072 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%I64d\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
double x[MAXN], r[MAXN], ans[MAXN];

int main()
{
    int n;
    ni(n);
    stack<int> st;
    for (int i = 0; i < n; i++)
    {
        scanf("%lf %lf", &x[i], &r[i]);
        ans[i] = r[i];
        while (!st.empty())
        {
            int j = st.top();
            ans[i] = min(ans[i], (x[i] - x[j]) * (x[i] - x[j]) / (4. * ans[j]));
            if (ans[i] > ans[j])
                st.pop();
            else
                break;
        }
        st.push(i);
        printf("%.20f\n", ans[i]);
    }
    return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:7:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define ni(n) scanf("%d", &(n))
               ~~~~~^~~~~~~~~~~~
bal.cpp:35:5: note: in expansion of macro 'ni'
     ni(n);
     ^~
bal.cpp:39:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lf %lf", &x[i], &r[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1528 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 77 ms 3492 KB 50000 numbers
2 Correct 50 ms 3832 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 171 ms 6712 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 198 ms 7960 KB 115362 numbers
2 Correct 113 ms 8520 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 270 ms 10228 KB 154271 numbers
2 Correct 188 ms 14032 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 308 ms 12688 KB 200000 numbers
2 Correct 185 ms 14072 KB 199945 numbers