Submission #386047

# Submission time Handle Problem Language Result Execution time Memory
386047 2021-04-05T13:56:44 Z ArianKheirandish Balloons (CEOI11_bal) C++14
100 / 100
229 ms 10348 KB
//in the name of god//
// SOBHET BEKHEIR JOOOOOOON E DEL

#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef long long ll;
#define all(x)	x.begin(),x.end()
#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define pll pair<ll,ll>

const int maxn = 2e6 + 10;
const int MAX = 110;
const int inf = 1e9 + 10;
const int mod = 1e9 + 7;
int n;
double x[maxn], mxr[maxn], r[maxn];
stack < pair <double, double > > s;

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

    r[1] = mxr[1];
    s.push(MP(x[1], mxr[1]));

    for(int i = 2; i <= n ; i++){
        r[i] = mxr[i];

        while (!s.empty()) {
            auto top = s.top();
            double prevX = top.F;
            double prevR = top.S;

            r[i] = min(r[i], (x[i] - prevX)*(x[i] - prevX)/(4 * prevR));

            if (r[i] >= prevR)
                s.pop();

            else
                break;
        }

        s.push(MP(x[i], r[i]));
    }

    for(int i = 1 ; i <= n ; i ++)
        cout << fixed << setprecision(3) << r[i] << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1260 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 60 ms 2924 KB 50000 numbers
2 Correct 58 ms 2796 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 128 ms 5228 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 143 ms 5996 KB 115362 numbers
2 Correct 144 ms 6308 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 190 ms 7788 KB 154271 numbers
2 Correct 220 ms 10348 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 229 ms 9472 KB 200000 numbers
2 Correct 219 ms 10348 KB 199945 numbers