Submission #535309

# Submission time Handle Problem Language Result Execution time Memory
535309 2022-03-10T02:02:09 Z tphuc2908 Balloons (CEOI11_bal) C++14
100 / 100
147 ms 8504 KB
#include<bits/stdc++.h>

using namespace std;
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define repi(i,x,y) for(int i = x; i >= y; --i)
#define ci(x) int x; cin>> x
#define TC(t) ci(t); while(t--)
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define cii(x, y) ci(x); ci(y)
#define ciii(x, y, z) ci(x); ci(y); ci(z)
#define mp make_pair
//#define int long long
typedef long long ll;
typedef vector<int> vi;
const int N = 2e5 + 5;
const int NN = 16 + 15;
const int mod =  998244353;
const int mod1 = 1e9 + 9;
const int pi = 31;
const int inf = 1e9 + 6;
const int block = 500;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
const int base = 1e9;
typedef vector<int> bignum;

void readfile(){
    #ifdef ONLINE_JUDGE
    #else
        freopen("text.inp", "r", stdin);
    #endif // ONLINE_JUDGE
//    freopen("text.inp", "r", stdin);
//    freopen("template.out", "w", stdout);
}

int n;
long long a[N], r[N];

void inp(){
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i] >> r[i];
}

void process(){
    stack<pair<int,double> > st;
    for(int i = 1; i <= n; ++i){
        double res = r[i];
        while(!st.empty()){
            long long temp1 = (a[i] - st.top().first) * 1LL * (a[i] - st.top().first);
            double temp = temp1;
            double rr = temp / (4.0 * st.top().second);
            res = min(res, rr);
            if(res >= st.top().second) st.pop();
            else break;
        }
        cout << fixed << setprecision(3) << res << '\n';
        st.push(make_pair(a[i], res));
    }
}

int main() {
//    readfile();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
//    int t; cin >> t >> opt;
//    while(t--){
        inp();
        process();
//    }
    return 0;
}

Compilation message

bal.cpp: In function 'void readfile()':
bal.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen("text.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 260 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 15 ms 724 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 47 ms 1700 KB 50000 numbers
2 Correct 32 ms 2388 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 96 ms 2796 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 81 ms 3240 KB 115362 numbers
2 Correct 84 ms 5208 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 115 ms 4132 KB 154271 numbers
2 Correct 117 ms 8504 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 147 ms 4944 KB 200000 numbers
2 Correct 116 ms 8468 KB 199945 numbers