제출 #649950

#제출 시각아이디문제언어결과실행 시간메모리
649950ymmBalloons (CEOI11_bal)C++17
20 / 100
2076 ms4016 KiB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

typedef pair<double, double> pdd;

pdd in()
{
	ll x, y;
	cin >> x >> y;
	return {x, y};
}

const int N = 200'010;

double a[N], b[N];
int len = 0;

void insert(pdd f)
{
	a[len] = f.first;
	b[len] = f.second;
	++len;
}

__attribute__((optimize("Ofast,unroll-loops"),target("avx2,fma")))
double get_0(double x)
{
	#define MIN(x, y) ((x)>(y)?(y):(x))
	double ans = 1e30;
	Loop (i,0,len) {
		double tmp = a[i]*x + b[i];
		ans = MIN(ans, tmp);
	}
	return ans;
	#undef MIN
}

__attribute__((optimize("Ofast,unroll-loops"),target("avx2,fma")))
double get_1(double x)
{
	#define MIN(x, y) ((x)>(y)?(y):(x))
	double ans = 1e30;
	Loop (i,len-len%8,len) {
		double tmp = a[i]*x + b[i];
		ans = MIN(ans, tmp);
	}
	typedef double ymm __attribute__((vector_size(32),aligned(32)));
	ymm vans = {ans, ans, ans, ans};
	LoopR (i,0,len/8) {
		ymm tmp = ((ymm *)a)[i]*x + ((ymm *)b)[i];
		vans = MIN(vans, tmp);
	}
	Loop (i,0,4)
		ans = MIN(ans, vans[i]);
	return ans;
	#undef MIN
}

double (*get_ans[2])(double x) = {get_0, get_1};

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	cout << fixed << setprecision(3);
	int n;
	cin >> n;
	Loop (i,0,n) {
		auto [x, r] = in();
		r = sqrt(r);
		r = min(r, get_ans[i&1](x));
		cout << r*r << '\n';
		insert({0.5/r, -x*0.5/r});
	}
}
#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...