Submission #680122

# Submission time Handle Problem Language Result Execution time Memory
680122 2023-01-10T00:50:23 Z bane Balloons (CEOI11_bal) C++17
100 / 100
183 ms 10188 KB
#include<bits/stdc++.h>
using namespace std;
           
using ll = long long;
using db = long double;
using llu = unsigned long long;
using str = string;
           
// pairs
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdb = pair<db,db>;
#define mp make_pair
#define fr first
#define sc second
           
#define tcT template<class T
#define tcTU tcT, class U
tcT> using V = vector<T>; 
tcT, size_t SZ> using AR = array<T,SZ>; 
using vi = V<int>;
using vb = V<bool>;
using vl = V<ll>;
using vd = V<db>;
using vs = V<str>;
using vpi = V<pii>;
using vpl = V<pll>;
using vpd = V<pdb>;
#define ms0(x) memset(x , 0, sizeof(x))
#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend() 
#define sor(x) sort(all(x)) 
#define rsz resize
#define ins insert 
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()
           
#define lb lower_bound
#define ub upper_bound
tcT> int lwb(V<T>& a, const T& b) { return int(lb(all(a),b)-bg(a)); }
tcT> int upb(V<T>& a, const T& b) { return int(ub(all(a),b)-bg(a)); }
           
// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rep(a) F0R(_,a)
#define each(a,x) for (auto& a: x)
           
const int MOD = (int)2019201949; // 998244353;
const int MX = (int)2e5+5;
const ll BIG = 1e18; 
const db PI = acos((db)-1);
using ld = long double;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};

void setIO(string name = "") {
    cin.tie(0)->sync_with_stdio(0); 
    if (sz(name)) {
        freopen((name + ".in").c_str(), "r", stdin); 
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

 
void solve(){
    int n;
    cin >> n;
    vector<pair<double,double>>a(n);
    for (int i = 0; i<n; i++){
        cin >> a[i].fr >> a[i].sc;
    }
    stack<pair<double,double>>s;
    double ans[n];
    ans[0] = a[0].sc;
    s.push(mp(a[0].sc, a[0].fr));
    for (int i = 1; i<n; i++){
        double r = a[i].sc;
        while(!s.empty()){
            double dist = ((double)a[i].fr - s.top().sc) * ((double)a[i].fr - s.top().sc) / ((double) 4 * s.top().fr);
            r = min(dist, r);
                
            if (r >= s.top().fr){
                //can fully inflate
                s.pop();
            }else{
                break;
            }
        }
        ans[i] = r;
        s.push(mp(r, a[i].fr));
    }
    for (int i = 0; i < n; i++)cout<<ans[i]<<'\n';
}
 
int main() {
    setIO("");
    cout<<fixed<<setprecision(3);
 // freopen("input.txt", "r", stdin);
   //freopen("output.txt", "w", stdout);
    solve();
    return 0;   
}

Compilation message

bal.cpp: In function 'void setIO(std::string)':
bal.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |         freopen((name + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:67:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |         freopen((name + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 212 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 18 ms 900 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 49 ms 2004 KB 50000 numbers
2 Correct 51 ms 2736 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 104 ms 3588 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 111 ms 4184 KB 115362 numbers
2 Correct 109 ms 6144 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 150 ms 5392 KB 154271 numbers
2 Correct 173 ms 10116 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 183 ms 6520 KB 200000 numbers
2 Correct 174 ms 10188 KB 199945 numbers