Submission #356807

# Submission time Handle Problem Language Result Execution time Memory
356807 2021-01-23T17:42:44 Z jnk Balloons (CEOI11_bal) C++17
70 / 100
2000 ms 19632 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

double x[200005], r[200005], res[200005];

int main(){
    
    int n; cin >> n;
    for(int i = 0; i < n; i++)
        scanf("%lf %lf", &x[i], &r[i]);

    res[0] = r[0];
    stack<pair<double,double>> st;
    st.push(make_pair(x[0], res[0]));

    for(int i = 1; i < n; i++){
        double esq = 0, dir = r[i];
        for(int j = 0; j < 45; j++){
            double r = (esq + dir)/2;
            int ok = 1;
            vector<pair<double,double>> safe;
            while(!st.empty()){
                auto p = st.top();
                double xdif = x[i] - p.first;
                double ydif = r - p.second;
                double dist = r+p.second;

                if(xdif*xdif + ydif*ydif < dist*dist){
                    ok = 0;
                    break;
                }
                if(r > p.second) st.pop(), safe.push_back(p);
                else break;
            }

            if(ok) esq = r;
            else dir = r;
            reverse(safe.begin(), safe.end());
            for(auto par : safe)
                st.push(par);
        }
        res[i] = esq;
        st.push(make_pair(x[i], res[i]));
    }

    for(int i = 0; i < n; i++)
        printf("%.3f\n", res[i]);

	return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:47:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   47 |     for(int i = 0; i < n; i++)
      |     ^~~
bal.cpp:50:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   50 |  return 0;
      |  ^~~~~~
bal.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |         scanf("%lf %lf", &x[i], &r[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 364 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 7 ms 492 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 71 ms 1572 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 1433 ms 4036 KB 50000 numbers
2 Correct 131 ms 5260 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2056 ms 7296 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2068 ms 5548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1756 ms 12884 KB 154271 numbers
2 Correct 566 ms 19632 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Execution timed out 2009 ms 6028 KB Time limit exceeded
2 Halted 0 ms 0 KB -