Submission #865017

#TimeUsernameProblemLanguageResultExecution timeMemory
865017nnhzzzBalloons (CEOI11_bal)C++14
100 / 100
414 ms8860 KiB
#include<bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i = (a); i<=(b); ++i)
#define REPD(i,a,b) for(int i = (a); i>=(b); --i)
#define REPDIS(i,a,b,c) for(int i = (a); i<=(b); i += c)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define BIT(x,i) ((x>>i)&1LL)
#define MASK(i) (1LL<<i)
#define fi first
#define se second
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ll long long
#define ld long double
#define MP make_pair

//---------------------------------------------------------------------------------------//
const int inf = 1e9,LOG = 18,MAXN = 5e5+7,N = 1e2+3;
const int MOD = 1e9+7,MOD1 = 1e9+207,MOD2 = 1e9+407,MOD3 = 998244353;
//---------------------------------------------------------------------------------------//
template<typename T> bool mini(T &a, const T &b){if(a>b){a=b;return true;} return false;}
template<typename T> bool maxi(T &a, const T &b){if(a<b){a=b;return true;} return false;}
//---------------------------------------------------------------------------------------//

ld sqr(ld x){ return (ld)x*x; }

void solve(){
    int n; cin >> n;
    stack<pair<ld,ld> > st;
    // st.push(MP(0,0));
    while(n--){
        ld x,r; cin >> x >> r;
        while(SZ(st)!=0){
            mini(r,sqr(x-st.top().fi)/st.top().se/4.0);
            if(r>st.top().se){
                st.pop();
            }else{
                break;
            }
        }
        st.push(MP(x,r));
        cout << fixed << setprecision(3) << r << endl;
    }
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define task "test"
    if(fopen(task".inp","r")){
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    #define task1 "nnhzzz"
    if(fopen(task1".inp","r")){
        freopen(task1".inp","r",stdin);
        freopen(task1".out","w",stdout);
    }
    solve();
    return 0;
}

Compilation message (stderr)

bal.cpp: In function 'int main()':
bal.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bal.cpp:58:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen(task1".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen(task1".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...