Submission #951200

# Submission time Handle Problem Language Result Execution time Memory
951200 2024-03-21T11:03:37 Z seriouslyFlawed Balloons (CEOI11_bal) C++17
100 / 100
179 ms 11788 KB
//#pragma GCC optimize("03,unroll-loops")

#include <bits/stdc++.h>

using namespace std;

// Shortcuts for common operations
#define pb push_back
#define p push
#define ppb pop_back
#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define ll long long
//#define int ll
#define endl "\n"
#define sz(x) (int)x.size()

// Type definitions for convenience
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vi> vvi;
typedef vector<pii> vii;

// Debugging macros
#define debug(x) cerr << #x << " = " << (x) << '\n'
#define debug_vector(v) _debug_vector(#v, v)
template<typename T>
void _debug_vector(const string& name, const vector<T>& a) {
    cerr << name << " = [ ";
    for(const auto &x : a) cerr << x << ' ';
    cerr << "]\n";
}

// I/O redirection for local testing
#define iofile(io) \
        freopen((io + ".in").c_str(), "r", stdin); \
        freopen((io + ".out").c_str(), "w", stdout);

// delta for floodfill
vi dx = {0, 1, 0, -1};
vi dy = {1, 0, -1, 0};

// extended deltas for floodfill
vi edx = {0, 1, 0, -1, 1, 1, -1, -1};
vi edy = {1, 0, -1, 0, 1, -1, 1, -1};

// Common outputs
void yes() { cout << "YES" << '\n'; }
void no() { cout << "NO" << '\n'; }

#define ld long double

ld radi(ld x, ld x1, ld r1){
    return (x1 - x)*(x1 - x)/(4*r1);
}

void fx() {
    int n;
    cin >> n;
    vector<pair<ld, ld>> tab(n);

    stack<pair<ld, ld>>s;
    
    for(int iter = 0; iter < n; iter++){
        cin >> tab[iter].f >> tab[iter].s;
        auto [x, r] = tab[iter];

        while(!s.empty()){ 
            r = min(r, radi(x, s.top().f, s.top().s));
            if(r >= s.top().s) s.pop();
            else break;
        }
        if(s.empty()) s.push({x, r});
        else s.push({x, r});

        cout << fixed << setprecision(3) << s.top().s << endl;
    }

}

signed main() {

    cin.tie(0)->sync_with_stdio(0);
    // Uncomment the following lines for file I/O
    // iofile(string("hello"));
    
    // Uncomment the following lines for multiple test cases
    // int t; cin >> t; while(t--) fx();
    
    // Single test case
    fx();
    
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 17 ms 1372 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 51 ms 3492 KB 50000 numbers
2 Correct 42 ms 3296 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 92 ms 6120 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 114 ms 7112 KB 115362 numbers
2 Correct 98 ms 7252 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 139 ms 9152 KB 154271 numbers
2 Correct 169 ms 11724 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 179 ms 10896 KB 200000 numbers
2 Correct 173 ms 11788 KB 199945 numbers