Submission #475047

# Submission time Handle Problem Language Result Execution time Memory
475047 2021-09-20T20:09:45 Z urosk Balloons (CEOI11_bal) C++14
100 / 100
214 ms 10112 KB
// __builtin_popcount(x) broj bitova
// __builtin_popcountll(x) long long
#define here cerr<<"---------------------------\n"
#include "bits/stdc++.h"
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll long long
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ld>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define rall(a) a.begin(),a.end(),greater<int>()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void setIO(string inoutname)
{
	freopen((inoutname+".in").c_str(),"r",stdin);
    	freopen((inoutname+".out").c_str(),"w",stdout);
}
#define mod 1
ll gcd(ll a, ll b)
{
   if(b==0) return a;
   if(a==0) return b;
   if(a>=b)  return gcd(a%b,b);
   return  gcd(a,b%a);
}
ll lcm(ll a,ll b){
   return (a/gcd(a,b))*b;
}
ll add(ll a,ll b){
	a+=b;
	a+=mod;
	if(a>=mod) a%=mod;
	return a;
}
ll mul(ll a,ll b){return(a*b)%mod;}
#define maxn 200005
ll n;
pll a[maxn];
double ans[maxn];
ll kvad(ll x){return x*x;}
void tc(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
    cin >> n;
    cout<<fixed<<setprecision(3)<<endl;
    for(ll i = 1;i<=n;i++) cin >> a[i].fi >> a[i].sc;
    ans[1] = a[1].sc;
    stack<pll> s;
    s.push(a[1]);
    for(ll i = 2;i<=n;i++){
        ld R = a[i].sc;
        while(sz(s)){
            ll x = s.top().fi;
            ld r = s.top().sc;
            R = min(R,(1.0*kvad(x-a[i].fi))/(4.0*r));
            if(R>=s.top().sc) s.pop();
            else break;
        }
        ans[i] = R;
        s.push({a[i].fi,R});
    }
    for(ll i = 1;i<=n;i++) cout<<ans[i]<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);
	//setIO("lol");
	int t; t = 1;
	while(t--){
		tc();
	}
	return 0;
}

Compilation message

bal.cpp: In function 'void setIO(std::string)':
bal.cpp:32:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  freopen((inoutname+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:33:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |      freopen((inoutname+".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 1 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 3 ms 352 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 20 ms 1100 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 52 ms 2812 KB 50000 numbers
2 Correct 52 ms 2692 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 110 ms 5016 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 122 ms 5892 KB 115362 numbers
2 Correct 122 ms 6112 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 166 ms 7668 KB 154271 numbers
2 Correct 191 ms 10052 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 214 ms 9272 KB 200000 numbers
2 Correct 193 ms 10112 KB 199945 numbers