Submission #657628

# Submission time Handle Problem Language Result Execution time Memory
657628 2022-11-10T13:35:44 Z cpp219 Balloons (CEOI11_bal) C++17
100 / 100
230 ms 5556 KB
#include<bits/stdc++.h>
#define ll long long
#define ld double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 1e6 + 9;
const ll inf = 1e18 + 7;

ll n;
stack<pair<ld,ld>> st;

int main(){
    ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
    #define task "test"
    if (fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        //freopen(task".out","w",stdout);
    }
    cin>>n;
    for (ll i = 1;i <= n;i++){
        ld x,r; cin>>x>>r;
        while(!st.empty()){
            ld x1 = st.top().fs,r1 = st.top().sc;
            r = min(r,((x1 - x)*(x1 - x))/(4*r1));
            if (r < r1) break;
            else st.pop();
        }
        st.push({x,r});
        cout<<fixed<<setprecision(3)<<r<<"\n";
    }

}
/* be confident */

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 28 ms 664 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 83 ms 1520 KB 50000 numbers
2 Correct 54 ms 1548 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 111 ms 2736 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 129 ms 3128 KB 115362 numbers
2 Correct 128 ms 3296 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 174 ms 3940 KB 154271 numbers
2 Correct 215 ms 5352 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 230 ms 4556 KB 200000 numbers
2 Correct 199 ms 5556 KB 199945 numbers