Submission #488122

# Submission time Handle Problem Language Result Execution time Memory
488122 2021-11-17T21:12:40 Z Codurr Balloons (CEOI11_bal) C++14
100 / 100
193 ms 8508 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long //int main to signed main (Avoid if TC very close to limit)
#define ll long long
#define sz(x) (int)((x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f first
#define s second

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

//Imp consts
const int MOD=1e9+7;
const int MAXN=2e5+1;
const int INF=1e18+5;
const double pi=3.14159265358979323846;
const double ep=1e-20;

signed main() {
    setIO();
    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    stack<pair<int,double>> s;
    cout<<fixed<<setprecision(3);
    for(int i=0;i<n;i++) {
    	int x;
    	double r;
    	cin>>x>>r;
    	if(!i) {
    		cout<<r<<'\n';
    		s.push({x,r});
    	}
    	else {
    		while(!s.empty()) {
    			int x1=s.top().f;
    			double r1=s.top().s;
    			r=min(r,(double)((x-x1)*(x-x1))/(4.0*r1));
    			if(r>=r1) s.pop();
    			else break;
    		}
    		cout<<r<<"\n";
    		s.push({x,r});
    	}
    }
    
    return 0;
}

Compilation message

bal.cpp: In function 'void setIO(std::string)':
bal.cpp:15:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen((s+".in").c_str(),"r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen((s+".out").c_str(),"w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 26 ms 772 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 46 ms 1696 KB 50000 numbers
2 Correct 42 ms 2356 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 104 ms 2832 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 108 ms 3216 KB 115362 numbers
2 Correct 102 ms 5224 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 142 ms 4160 KB 154271 numbers
2 Correct 168 ms 8508 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 193 ms 5020 KB 200000 numbers
2 Correct 173 ms 8508 KB 199945 numbers