text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
const double EPS = (1e-10);
bool EQ(double a, double b) { return abs((a) - (b)) < EPS; }
void fast_stream() { std::ios_base::sync_with_stdio(0); }
double ts[100001];
double vs[100001];
void solve() {
int n, d, a;
cin >> n >> a >> d;
double prvTime = 0;
for (int i = 0; i < n; i++) {
cin >> ts[i] >> vs[i];
double t = vs[i] / a;
double tt;
if (0.5 * a * t * t > d || EQ(0.5 * a * t * t, d))
tt = sqrt(((double)2 * d) / a) + ts[i];
else {
double x = d - 0.5 * a * pow(vs[i] / a, 2.0);
double pt = x / vs[i];
tt = ts[i] + pt + vs[i] / a;
}
if (prvTime < tt)
printf("%.10f\n", tt);
else
printf("%.10f\n", prvTime);
prvTime = max(prvTime, tt);
}
}
int main() {
solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char *sdbg, TH h) {
cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char *sdbg, TH h, TA... t) {
while (*sdbg != ',') {
cerr << *sdbg++;
}
cerr << "=" << h << ",";
_dbg(sdbg + 1, t...);
}
template <class T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
return a * b / gcd(a, b);
}
vector<string> split(string s) {
istringstream buf(s);
istream_iterator<string> beg(buf), end;
vector<string> list(beg, end);
return list;
}
bool isvowel(char c) {
string s = "aeiouAEIOU";
if (find(s.begin(), s.end(), c) != s.end()) return true;
return false;
}
vector<long long> sieve(long long n) {
vector<bool> prime(n + 1, true);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= n; i++) {
if (prime[i])
for (int j = i * i; j <= n; j += i) {
prime[j] = 0;
}
}
vector<long long> p;
for (int i = 2; i <= prime.size(); i++)
if (prime[i]) p.push_back(i);
return p;
}
bool isprime(int n) {
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true && (n != 1);
}
int ncr(long long n, long long r) {
long long C[r + 1];
memset(C, 0, sizeof(C));
C[0] = 1;
for (long long i = 1; i <= n; i++) {
for (long long j = min(i, r); j > 0; j--)
C[j] = (C[j] + C[j - 1]) % 1000000007;
}
return C[r];
}
bool special(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == ' ') continue;
if (s[i] == '#')
return true;
else
return false;
}
return false;
}
void solve() {
cout << fixed << setprecision(10);
double n, a, d;
cin >> n >> a >> d;
vector<pair<double, double> > v(n);
double max_ans = 0;
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
double s1 = v[i].second * v[i].second / (2 * a);
double t = v[i].first;
if (d < s1) {
t += sqrt(2 * d / a);
} else {
t += v[i].second / a + (d - s1) / v[i].second;
}
t = max(t, max_ans);
cout << t << '\n';
max_ans = t;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double a, d;
cin >> n >> a >> d;
double t[100005], v[100005];
for (int i = 0; i < n; i++) cin >> t[i] >> v[i];
double ans[100005];
for (int i = 0; i < n; i++) {
double cur = min(sqrt(2 * d / a), v[i] / a);
double val = t[i] + (d - .5 * a * cur * cur) / v[i] + cur;
if (!i)
ans[i] = val;
else
ans[i] = max(ans[i - 1], val);
}
for (int i = 0; i < n; i++)
cout << setprecision(10) << fixed << ans[i] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
double a, d;
struct DD {
double t;
double v;
int id;
} bus[100010];
struct answer {
double t;
int id;
} ans[100010];
int cmp(const DD& a, const DD& b) { return a.t < b.t; }
int cmpt(const answer& a, const answer& b) { return a.id < b.id; }
int main() {
scanf("%d%lf%lf", &n, &a, &d);
for (int i = 0; i < n; i++) {
scanf("%lf%lf", &bus[i].t, &bus[i].v);
bus[i].id = i;
}
sort(bus, bus + n, cmp);
for (int i = 0; i < n; i++) {
double x = bus[i].v / a;
if (a * x * x / 2 > d) {
ans[i].t = bus[i].t + sqrt(2 * d / a);
} else {
ans[i].t = bus[i].t + x + (d - bus[i].v * x / 2) / bus[i].v;
}
if (i) {
ans[i].t = ((ans[i].t) > (ans[i - 1].t) ? (ans[i].t) : (ans[i - 1].t));
}
ans[i].id = bus[i].id;
}
sort(ans, ans + n, cmpt);
for (int i = 0; i < n; i++) {
printf("%.10lf\n", ans[i].t);
}
}
|
#include <bits/stdc++.h>
int main() {
double x, ans, Max = 0, a, d, t, v;
int n, i;
scanf("%d%lf%lf", &n, &a, &d);
for (i = 0; i < n; i++) {
scanf("%lf%lf", &t, &v);
x = v * v / 2 / a;
if (d > x) {
ans = t + v / a + (d - x) / v;
if (ans > Max) Max = ans;
} else {
ans = t + sqrt(2 * d / a);
if (ans > Max) Max = ans;
}
printf("%.9lf\n", Max);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, a, d, t[N], v[N];
long double ans[N];
long double get_time(long double t, long double v) {
long double tt = v / a;
long double x = a * tt * tt / 2;
if (x >= d) {
return t + sqrt(2.0 * d / a);
} else {
return t + tt + (d - x) / v;
}
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> a >> d;
for (long long i = 1; i <= n; i++) {
cin >> t[i] >> v[i];
ans[i] = max(ans[i - 1], get_time(t[i], v[i]));
}
for (long long i = 1; i <= n; i++) {
cout << fixed << setprecision(12) << ans[i] << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long int n, a, d, ti, vi;
scanf("%ld%ld%ld", &n, &a, &d);
double s, acc, t, p, vel, min = 0, disp;
for (int i = 0; i < n; i++) {
scanf("%ld%ld", &ti, &vi);
acc = a;
vel = vi;
s = d;
if ((vel * vel) / (2.0 * acc) > s)
t = sqrt(((2 * s) / acc));
else
t = (vel / acc) + ((s - ((vel * vel) / (2.0 * acc))) / vel);
if (i == 0) {
printf("%.10lf\n", t + ti);
min = t + ti;
} else {
if (ti + t <= min) {
printf("%.10lf\n", min);
} else {
printf("%.10lf\n", t + ti);
min = t + ti;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a, d, i, t, v;
long double ans, x;
long double f(int x) {
long double t0 = sqrt(2. * d / a);
if (t0 * a <= x) return t0;
t0 = 1. * x / a;
return t0 + (d - a * t0 * t0 / 2.) / x;
}
int main() {
cin >> n >> a >> d;
ans = 0;
for (i = 0; i < n; i++) {
cin >> t >> v;
x = t + f(v);
if (x > ans) ans = x;
cout << fixed << setprecision(9) << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int n, a, d;
int t, v;
double lt, ltv, lsv, ct;
scanf("%d%d%d%d%d", &n, &a, &d, &t, &v);
ltv = v * 1.0 / a;
lsv = 0.5 * a * ltv * ltv;
if (lsv > d) {
lt = t + sqrt(2.0 * d / a);
} else {
lt = t + ltv + (d - lsv) / v;
}
printf("%lf\n", lt);
n--;
while (n--) {
scanf("%d%d", &t, &v);
ltv = v * 1.0 / a;
lsv = 0.5 * a * ltv * ltv;
if (lsv > d) {
ct = t + sqrt(2.0 * d / a);
} else {
ct = t + ltv + (d - lsv) / v;
}
if (ct > lt) lt = ct;
printf("%lf\n", lt);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double a, d, t1, t2;
cin >> n >> a >> d;
vector<double> v(n), t(n);
for (int i = 0; i < n; ++i) cin >> t[i] >> v[i];
for (int i = 0; i < n; ++i)
if (i == 0)
if (sqrt(2 * d / a) <= v[0] / a) {
cout << fixed << setprecision(12) << t[0] + sqrt(2.0 * d / a) << "\n";
t1 = t[0] + sqrt(2.0 * d / a);
} else {
cout << fixed << setprecision(12)
<< t[0] + v[0] / a + (d - v[0] * v[0] / (2 * a)) / v[0] << "\n";
;
t1 = t[0] + v[0] / a + (d - v[0] * v[0] / (2 * a)) / v[0];
}
else {
if (sqrt(2 * d / a) <= v[i] / a)
t2 = t[i] + sqrt(2.0 * d / a);
else
t2 = t[i] + v[i] / a + (d - v[i] * v[i] / (2 * a)) / v[i];
if (t1 < t2) {
cout << fixed << setprecision(12) << t2 << "\n";
t1 = t2;
} else
cout << fixed << setprecision(12) << t1 << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int t[104000];
int v[101000];
int main() {
int n, a, d;
int i;
double x = 0;
scanf("%d%d%d", &n, &a, &d);
for (i = 0; i < n; ++i) {
scanf("%d%d", &t[i], &v[i]);
double dt = v[i] * 1.0 / a;
double ht;
if (0.5 * a * dt * dt > d) {
ht = sqrt((2 * d * 1.0 / a));
} else {
ht = dt + (d * 1.0 - 0.5 * a * dt * dt) / v[i];
}
ht = ht + t[i] * 1.0;
if (ht < x)
printf("%.7f\n", x);
else {
printf("%.7f\n", ht);
x = ht;
}
}
return 0;
}
|
#include <bits/stdc++.h>
double x[100010];
int main() {
int i, n;
double a, l;
scanf("%d%lf%lf", &n, &a, &l);
for (i = 0; i < n; i++) {
double t, v;
scanf("%lf%lf", &t, &v);
double ti = v / a;
double t2 = (l - 0.5 * a * ti * ti) / v;
if (0.5 * a * ti * ti > l) {
x[i] = t + sqrt(2 * l / a);
} else
x[i] = t + ti + t2;
}
for (int i = 0; i < n; i++) {
if (i > 0 && x[i] < x[i - 1]) x[i] = x[i - 1];
printf("%.10lf\n", x[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double inf = 1e9 + 7;
double t[100010], v[100010];
int n;
double a, d;
double ans[100010];
bool chk(double mid) {
for (int i = 0; i < n; i++) {
if (2 * a * d > v[i] * v[i])
ans[i] = t[i] + v[i] / a + (d - v[i] * v[i] / a / 2) / v[i];
else {
ans[i] = sqrt(2 * a * d) / a + t[i];
}
if (i == 0) {
if (ans[i] > mid)
return 0;
else
continue;
}
if (max(ans[i], ans[i - 1]) > mid) {
ans[i] = max(ans[i], ans[i - 1]);
return 0;
} else {
ans[i] = max(ans[i], ans[i - 1]);
continue;
}
}
return 1;
}
int main() {
scanf("%d%lf%lf", &n, &a, &d);
for (int i = 0; i < n; i++) {
scanf("%lf%lf", &t[i], &v[i]);
}
double r = inf, l = 0;
double len = inf;
double mid;
while (len > 0.00001) {
mid = (r + l) / 2;
if (chk(mid))
l = mid;
else
r = mid;
len /= 2;
}
for (int i = 0; i < n; i++) printf("%.5lf\n", ans[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
double t[100009], v[100009], sum[100009];
int main() {
int n;
double a, d;
while (~scanf("%d%lf%lf", &n, &a, &d)) {
for (int i = 0; i < n; i++) scanf("%lf%lf", &t[i], &v[i]);
double time = v[0] / a;
sum[0] = t[0] + time + (d - 0.5 * a * time * time) / v[0];
if (0.5 * a * time * time > d)
sum[0] = min(sum[0], t[0] + sqrt((2 * d) / a));
for (int i = 1; i < n; i++) {
double time1 = v[i] / a;
sum[i] = t[i] + time1 + (d - 0.5 * a * time1 * time1) / v[i];
if (0.5 * a * time1 * time1 > d)
sum[i] = min(sum[i], t[i] + sqrt((2 * d) / a));
sum[i] = max(sum[i], sum[i - 1]);
}
for (int i = 0; i < n; i++) printf("%.10f\n", sum[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, v, i, n, a, d;
double tp = 0;
cin >> n >> a >> d;
for (i = 0; i < n; ++i) {
cin >> t >> v;
double tr = v / 1.0 / a;
if (a * ((tr) * (tr)) / 2 > d) {
tr = sqrt(2.0 * d / a);
} else
tr += (d - a * ((tr) * (tr)) / 2) / v;
if (tp - tr - t < 0.0000001) tp = tr + t;
printf("%.6lf\n", tp);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, d;
cin >> n >> a >> d;
vector<int> t;
vector<int> v;
vector<int> ans;
int temp;
for (int i = 0; i < n; ++i) {
cin >> temp;
t.push_back(temp);
cin >> temp;
v.push_back(temp);
}
double cur = 0;
double tp = 0;
double curT = 0;
for (int i = 0; i < n; ++i) {
tp = v[i] * 1.0 / a;
if (a * tp * tp / 2.0 > d)
curT = t[i] + sqrt(2.0 * d / a);
else
curT = t[i] + tp + (d - a * tp * tp / 2.0) / v[i];
if (cur == 0) {
cur = curT;
printf("%f\n", curT);
} else {
if (curT > cur) {
cur = curT;
printf("%f\n", curT);
} else
printf("%f\n", cur);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double n, a, d;
while (cin >> n >> a >> d) {
pair<double, double> arr[int(n)];
double mn = -1;
for (int i = 0; i < n; i++) {
scanf("%lf%lf", &arr[i].first, &arr[i].second);
double dd = (arr[i].second * arr[i].second) / (2 * a);
double time;
if (d > dd) {
time = arr[i].second / a + (d - dd) / arr[i].second;
} else
time = sqrt(2 * d / a);
;
time += arr[i].first;
if (time < mn)
cout << setprecision(15) << mn << "\n";
else
cout << setprecision(15) << time << "\n";
if (time < mn)
mn = mn;
else
mn = time;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double a, d, t, vf;
scanf("%d %lf %lf", &n, &a, &d);
double bestP = -1;
for (int i = 0; i < n; i++) {
scanf("%lf%lf", &t, &vf);
double t1 = vf / a;
if ((vf * vf) / (2 * a) >= d)
t1 = sqrt(2.0 * d / a);
else {
double drest = d - (vf * vf) / (2 * a);
t1 += drest / vf;
}
double currP = t + t1;
if (currP < bestP) currP = bestP;
bestP = currP;
printf("%.10lf\n", currP);
}
}
|
#include <bits/stdc++.h>
using namespace std;
struct train {
double t = 0, v = 0, time = 0;
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
double ta, s, n, a, d, mx = -1;
cin >> n >> a >> d;
vector<train> trn(n);
for (int i = 0; i < n; i++) {
cin >> trn[i].t >> trn[i].v;
ta = trn[i].v / a;
s = (trn[i].v) * (trn[i].v) / (2 * a);
if (s > d)
trn[i].time = sqrt(2 * d / a) + trn[i].t;
else
trn[i].time = ta + (d - s) / trn[i].v + trn[i].t;
trn[i].time = max(mx, trn[i].time);
mx = trn[i].time;
cout << setprecision(12) << trn[i].time << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int i, j, k, n, m, A, d;
double t, t1 = 0, t2, t3;
scanf("%d%d%d", &n, &A, &d);
int a[100009][2];
for (i = 0; i < n; ++i) scanf("%d%d", &a[i][0], &a[i][1]);
t = sqrt(2.0 * d / (double)A);
for (i = 0; i < n; ++i) {
t3 = min(a[i][1] / (double)A, t);
t2 = (d - A * t3 * t3 / 2.0) / (double)a[i][1];
t1 = max(t1, t2 + t3 + a[i][0]);
printf("%0.5lf\n", t1);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int t[100000];
int v[100000];
double calculateBest(double t0, double v, double a, double d) {
if (d < v * v / 2 / a) {
return t0 + sqrt(2 * d / a);
}
return t0 + v / a + (d - v * v / 2 / a) / v;
}
int main() {
int n, a, d;
scanf("%d%d%d", &n, &a, &d);
for (int i = 0; i < n; ++i) {
scanf("%d%d", &t[i], &v[i]);
}
double tLast = numeric_limits<double>::infinity();
for (int i = 0; i < n; ++i) {
double tBest = calculateBest(t[i], v[i], a, d);
if (i != 0 && tBest < tLast) {
printf("%.10lf\n", tLast);
} else {
tLast = tBest;
printf("%.10lf\n", tLast);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double n, a, d;
scanf("%lf%lf%lf", &n, &a, &d);
double ans = 0;
for (int i = 0; i < n; i++) {
double v, t;
scanf("%lf%lf", &t, &v);
double arr_t = sqrt((2 * d) / a);
if (arr_t * a > v) arr_t = (d - 0.5 * v * v / a) / v + v / a;
ans = max(ans, arr_t + t);
printf("%.11lf\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return ((a * b) / gcd(a, b)); }
template <class T>
inline T bigmod(T p, T e, T M) {
long long ret = 1;
for (; e > 0; e >>= 1) {
if (e & 1) ret = (ret * p) % M;
p = (p * p) % M;
}
return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
if (b == 0) return a;
return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
return bigmod(a, M - 2, M);
}
long long powermod(long long base, long long exp, long long modulus) {
base %= modulus;
long long result = 1;
while (exp > 0) {
if (exp & 1) result = (result * base) % modulus;
base = (base * base) % modulus;
exp >>= 1;
}
return result;
}
using namespace std;
pair<double, double> arr[100005];
double t[100005];
int main() {
long long i, j, k, l, m, n;
double a, d;
cin >> n >> a >> d;
for (i = 0; i < n; i++) {
scanf("%lf %lf", &arr[i].first, &arr[i].second);
}
for (i = 0; i < n; i++) {
double x = ((double)arr[i].second / a);
double y = (x / 2.0) * (x)*a;
if (y <= d) {
double z = (d - y);
x += (z / arr[i].second);
} else {
x = sqrt((2 * d) / a);
}
t[i] = x + (double)arr[i].first;
}
printf("%.10f\n", t[0]);
for (i = 1; i < n; i++) {
t[i] = max(t[i], t[i - 1]);
printf("%.10f\n", t[i]);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int DEBUG = 0;
double Min(double a, double b) { return (a < b ? a : b); }
double Max(double a, double b) { return (a > b ? a : b); }
double Abs(double a) { return (a >= 0 ? a : -a); }
void print1d(int *vec, int M, const char *str = NULL) {
if (str != NULL) printf("%s ", str);
for (int i = 0; i < M; i++) {
if (i > 0) printf(" ");
printf("%d", vec[i]);
}
printf("\n");
}
struct NODE {
double t, v;
};
int compare_NODE_inc(const void *a_, const void *b_) {
NODE *a = (NODE *)a_;
NODE *b = (NODE *)b_;
if (a->t > b->t)
return 1;
else if (a->t < b->t)
return -1;
else
return 0;
}
int main(int argc, char **argv) {
DEBUG = (argc >= 2) ? atoi(argv[1]) : 0;
int n;
double a, d;
cin >> n >> a >> d;
NODE bus[n];
for (int i = 0; i < n; i++) {
cin >> bus[i].t >> bus[i].v;
}
qsort(bus, n, sizeof(NODE), compare_NODE_inc);
double prevt = 0;
double tim;
for (int i = 0; i < n; i++) {
double t = bus[i].t;
double v = bus[i].v;
if (v * v >= 2.0 * a * d) {
tim = t + sqrt(2.0 * d / a);
} else {
tim = t + (1.0 * d / v + 1.0 * v / 2.0 / a);
}
prevt = Max(tim, prevt);
printf("%.10lf\n", prevt);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double a, d, m = 0;
scanf("%d %lf %lf", &n, &a, &d);
double v[n], t[n];
for (int i = 0; i < n; i++) scanf("%lf %lf", &t[i], &v[i]);
for (int i = 0; i < n; i++) {
double t1 = v[i] / a, d1 = (v[i] * v[i]) / (2 * a), t2 = 0;
if (d1 <= d)
t2 = (d - d1) / v[i];
else
t1 = sqrt(2 * d / a);
m = max(m, t[i] + t1 + t2);
printf("%.8lf\n", m);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
int n, a, d;
int dt, dv;
double getTime(double maxv) {
double t = maxv / a;
double s = a * t * t / 2;
if (s > d + eps) {
return sqrt(d * 2.0 / a);
} else {
return t + (d - s) / maxv;
}
}
int main() {
double pt = -0.0, t;
scanf("%d %d %d", &n, &a, &d);
for (int i = 0; i < n; ++i) {
scanf("%d %d", &dt, &dv);
t = dt + getTime(dv);
if (t > pt + eps) {
printf("%lf\n", t);
pt = t;
} else
printf("%lf\n", pt);
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int n, i, j, l;
double d, a, t[100000], v[100000], time[100000], t1, s1;
scanf("%d %lf %lf", &n, &a, &d);
for (i = 0; i < n; i++) {
scanf("%lf %lf", &t[i], &v[i]);
t1 = v[i] / a;
s1 = 0.5 * a * t1 * t1;
if (s1 >= d) {
time[i] = sqrt(2 * d / a) + t[i];
} else
time[i] = (d - s1) / v[i] + t1 + t[i];
if (i > 0 && time[i] < time[i - 1]) time[i] = time[i - 1];
printf("%.10lf\n", time[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
const long long mod = 1000000007;
const long long Inf = 1e9;
using namespace std;
bool valid(string s) {
for (int i = 0; i < s.length(); ++i) {
if (s[i] == ' ' || s[i] == '#') {
if (s[i] == '#') return true;
} else
return false;
}
return false;
}
string wtSpace(string s) {
string res = "";
for (int i = 0; i < s.length(); ++i) {
if (s[i] != ' ') res += s[i];
}
return res;
}
int main() {
int n, a, d;
scanf("%d %d %d", &n, &a, &d);
vector<double> ans(n);
for (int i = 0; i < n; i++) {
int t, v;
scanf("%d %d", &t, &v);
double time = pow(2 * d / (double)a, 0.5);
double time2 = v / (double)a;
if (time <= time2)
ans[i] = t + time;
else {
double x = a * pow(time2, 2) / 2.0;
ans[i] = t + time2 + (d - x) / (double)v;
}
}
for (int i = 0; i < n - 1; i++) {
if (ans[i + 1] < ans[i]) ans[i + 1] = ans[i];
printf("%.6f\n", ans[i]);
}
printf("%.6f\n", ans[n - 1]);
return 0;
}
|
#include <bits/stdc++.h>
const long long mod = 1000000007;
using namespace std;
template <typename T>
void printV(vector<T>& v) {
for (int i = 0; i < (int)(v.size()); i++) cout << v[i] << " ";
cout << endl;
}
template <typename T>
void printVs(vector<vector<T> >& v) {
for (int i = 0; i < (int)(v.size()); i++) printV(v[i]);
}
const int N = 600000;
const char aa = 'a';
int main(int argc, const char* argv[]) {
int n, a, d;
cin >> n >> a >> d;
vector<int> v(n), t(n);
for (int i = 0; i < (int)(n); i++) cin >> t[i] >> v[i];
vector<double> T(n);
for (int i = 0; i < (int)(n); i++) {
double tm = v[i] / (a + 0.0);
if (tm * v[i] / 2 >= d)
T[i] = sqrt(d * 2 / (a + 0.0));
else
T[i] = tm + (d - tm * v[i] / 2) / (v[i] + 0.0);
T[i] += t[i];
if (i) T[i] = max(T[i], T[i - 1]);
}
setprecision(10);
for (int i = 0; i < (int)(n); i++) {
cout << fixed;
cout << T[i] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
double a, d;
double v[100500];
double t[100500];
int main() {
scanf("%d %lf %lf", &n, &a, &d);
double x, ant;
x = 0;
ant = 0;
double ds = 0;
for (int i = 0; i < n; i++) {
scanf("%lf %lf", &t[i], &v[i]);
x = t[i] + (v[i] / a);
ds = (v[i] * v[i]) / (2 * a);
if (ds + 10e-9 > d) {
x = t[i] + sqrt((2 * d) / a);
if (x < ant + 10e-9) {
printf("%.15lf\n", ant);
} else {
printf("%.15lf\n", x);
ant = x;
}
} else {
ds = d - ds;
x = x + (ds / v[i]);
if (x < ant + 10e-9) {
printf("%.15lf\n", ant);
} else {
printf("%.15lf\n", x);
ant = x;
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const double err = 1e-9;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;
int main() {
int n;
double tc, a, d, v, ts;
scanf("%d%lf%lf", &n, &a, &d);
double lv = -1;
while (n--) {
scanf("%lf%lf", &ts, &v);
double s = (v * v) / (2.0 * a);
if (s <= d)
tc = sqrt(2.0 * s / a) + (d - s) / v + ts;
else
tc = sqrt(2.0 * d / a) + ts;
if (lv == -1 || lv < tc)
lv = tc;
else if (lv > tc)
tc = lv;
printf("%.10lf\n", tc);
}
return 0;
}
|
#include <bits/stdc++.h>
int main(void) {
int n, a, d;
int *t, *v;
double *ans;
int i, j;
double x, doc;
scanf("%d %d %d", &n, &a, &d);
t = (int *)calloc(n, sizeof(int));
v = (int *)calloc(n, sizeof(int));
ans = (double *)calloc(n, sizeof(double));
for (i = 0; i < n; i++) {
scanf("%d %d", (t + i), (v + i));
}
for (i = 0; i < n; i++) {
if ((double)v[i] * v[i] / (2 * a) > d) {
*(ans + i) = sqrt(2 * (double)d / a) + t[i];
} else {
*(ans + i) = (d + (double)v[i] * v[i] / (2 * a)) / v[i] + t[i];
}
}
for (i = 1; i < n; i++) {
if (*(ans + i) < *(ans + i - 1)) {
*(ans + i) = *(ans + i - 1);
}
}
for (i = 0; i < n; i++) {
printf("%.10f\n", *(ans + i));
}
free(t);
free(v);
free(ans);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long INF64 = (long long)1e18;
const long double eps = 1e-9;
const long double pi = 3.14159265358979323846;
struct troll {
int t, v, n;
};
int main() {
int n, a, d;
scanf("%d%d%d", &n, &a, &d);
vector<int> time(n), speed(n);
for (int i = 0; i < int(n); ++i) scanf("%d%d", &time[i], &speed[i]);
double prev = -INF;
for (int i = 0; i < n; i++) {
double t = double(time[i]);
double v = double(speed[i]);
double aa = double(a);
double dd = double(d);
double l = 0, r = 100000000;
for (int iter = 0; iter < int(100); ++iter) {
double t0 = (l + r) / 2;
double ta = v / aa;
if (ta - eps > t0) ta = t0;
double dist = ta / 2 * ta * aa;
if (ta + eps < t0) dist += v * (t0 - ta);
if (dist + eps > dd)
r = t0;
else
l = t0;
}
l += t;
if (l - eps > prev) {
printf("%0.6lf\n", l);
prev = l;
} else
printf("%0.6lf\n", prev);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, -1, 0};
int dy[] = {1, 0, 0, -1};
long long pw(long long b, long long p) {
if (!p) return 1;
long long sq = pw(b, p / 2);
sq *= sq;
if (p % 2) sq *= b;
return sq;
}
const int N = 3e5 + 10, M = N * 2;
int idx = 1;
vector<int> q;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
double n, a, d;
cin >> n >> a >> d;
double mx = 0;
for (int i = 0; i < n; i++) {
double res = 0;
double t, v;
cin >> t >> v;
double x = v / a;
double dist = (a * x * x) / 2.0;
if (d >= dist) {
res = x + (d - dist) / v + t;
} else
res = sqrt(2 * d / a) + t;
mx = max(mx, res);
cout << fixed << setprecision(10) << mx << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void file() {}
void fast() {
std::ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
}
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long setbit(long long num, int idx, int val = 1) {
return (val) ? (num | (1 << idx)) : (num & ~(1 << idx));
}
long long getbit(long long num, int idx) { return ((num >> idx) & 1) == 1; }
int contbit(int num) {
int ret = 0;
while (num) {
if (num % 2) ret++;
num /= 2;
}
return ret;
}
int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
int main() {
cout << fixed << setprecision(6);
file();
fast();
int n;
double a, d, mxT = 0;
cin >> n >> a >> d;
double mxV = sqrt(2 * a * d);
while (n--) {
double t, v;
cin >> t >> v;
if (v >= mxV) {
v = mxV;
t += 2 * d / v;
} else {
double d1 = v * v / (2 * a);
double d2 = d - d1;
t += d2 / v;
t += v / a;
}
mxT = max(t, mxT);
cout << mxT << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
using namespace std;
double getTime(double t, double a, double v, double d) {
double tMaxV = v / a;
double tMaxA = sqrt(2 * d / a);
if (tMaxV > tMaxA)
return t + tMaxA;
else {
double dMaxA = a * ((tMaxV) * (tMaxV)) / 2;
return t + tMaxV + (d - dMaxA) / v;
}
}
int main() {
double n, a, d;
cin >> n >> a >> d;
vector<int> t, v;
for (int i = 0; i < (n); i++) {
double tv, tt;
cin >> tt >> tv;
t.push_back(tt);
v.push_back(tv);
}
double min = getTime(t[0], a, v[0], d);
for (int i = 0; i < (n); i++) {
double iT = getTime(t[i], a, v[i], d);
if (min < iT) {
min = iT;
printf("%f\n", iT);
} else
printf("%f\n", min);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T inline SQR(const T &a) {
return a * a;
}
int main() {
ios::sync_with_stdio(false);
int n;
double a, d;
cin >> n >> a >> d;
cout << fixed << setprecision(10);
vector<pair<double, double> > vec(n);
for (int i = 0; i < n; ++i) cin >> vec[i].first >> vec[i].second;
double t = sqrt(2. * d / a);
vector<double> times(n);
for (int i = 0; i < n; ++i) {
double tvm = vec[i].second / a;
if (tvm >= t) {
if (i == 0) {
times[i] = vec[i].first + t;
cout << times[i] << '\n';
} else {
times[i] = max(vec[i].first + t, times[i - 1]);
cout << times[i] << '\n';
}
} else {
double dr = d - (a * (vec[i].second / a) * (vec[i].second / a)) / 2.;
double yo = vec[i].first + tvm + dr / vec[i].second;
if (i == 0) {
times[i] = yo;
cout << times[i] << '\n';
} else {
times[i] = max(yo, times[i - 1]);
cout << times[i] << '\n';
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char *sdbg, TH h) {
cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char *sdbg, TH h, TA... t) {
while (*sdbg != ',') {
cerr << *sdbg++;
}
cerr << "=" << h << ",";
_dbg(sdbg + 1, t...);
}
template <class T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
return a * b / gcd(a, b);
}
vector<string> split(string s) {
istringstream buf(s);
istream_iterator<string> beg(buf), end;
vector<string> list(beg, end);
return list;
}
bool isvowel(char c) {
string s = "aeiouAEIOU";
if (find(s.begin(), s.end(), c) != s.end()) return true;
return false;
}
vector<long long> sieve(long long n) {
vector<bool> prime(n + 1, true);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= n; i++) {
if (prime[i])
for (int j = i * i; j <= n; j += i) {
prime[j] = 0;
}
}
vector<long long> p;
for (int i = 2; i <= prime.size(); i++)
if (prime[i]) p.push_back(i);
return p;
}
bool isprime(int n) {
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true && (n != 1);
}
int ncr(long long n, long long r) {
long long C[r + 1];
memset(C, 0, sizeof(C));
C[0] = 1;
for (long long i = 1; i <= n; i++) {
for (long long j = min(i, r); j > 0; j--)
C[j] = (C[j] + C[j - 1]) % 1000000007;
}
return C[r];
}
bool special(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == ' ') continue;
if (s[i] == '#')
return true;
else
return false;
}
return false;
}
void solve() {
cout << fixed << setprecision(10);
int n;
double a, d;
cin >> n >> a >> d;
double max_ans = 0;
int t1, v;
for (int i = 0; i < n; i++) {
cin >> t1 >> v;
double s1 = 1.0 * v * v / (2 * a);
double t = t1;
if (d < s1)
t += sqrt(2 * d / a);
else
t += 1.0 * v / a + (d - s1) / v;
max_ans = max(t, max_ans);
cout << max_ans << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double n, acc, dis;
cin >> n >> acc >> dis;
double ma = 0;
for (int i = 0; i < n; i++) {
double ftime, maspeed;
scanf("%lf%lf", &ftime, &maspeed);
double macc = (maspeed * maspeed) / (2 * acc);
if (macc >= dis)
ftime += sqrt((2 * dis) / acc);
else {
ftime += ((maspeed / acc) + (dis - macc) / maspeed);
}
ma = max(ftime, ma);
ftime = max(ftime, ma);
printf("%.12lf\n", ftime);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
unsigned long long n, a, d;
cin >> n >> a >> d;
vector<unsigned long long> tl(n), v(n);
vector<double> ta(n);
double pre = 0;
for (unsigned long long i = (0); i < (n); i++) {
cin >> tl[i] >> v[i];
double t = v[i] / (double)a;
double l = (t * v[i] / 2.0);
if (l >= d) {
ta[i] = sqrt(d * 2.0 / a);
} else {
l = d - l;
t += l / v[i];
ta[i] = t;
}
ta[i] += tl[i];
if (pre >= ta[i]) {
ta[i] = pre;
}
pre = ta[i];
}
for (unsigned long long i = (0); i < (n); i++) {
cout << setiosflags(ios::fixed) << setprecision(5) << ta[i] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Node {
double t;
double v, size;
} q[100005];
int main(int argc, char** argv) {
int n, a;
double d;
cin >> n >> a >> d;
double t1, t2, t;
double x1, x;
for (int i = 0; i < n; i++) {
scanf("%lf %lf", &q[i].t, &q[i].v);
x1 = q[i].v * q[i].v / 2.0 / a;
t1 = q[i].v / double(a);
if (x1 < double(d)) {
t2 = double(d - x1) / double(q[i].v);
t = t1 + t2;
} else {
t = sqrt(2.0 * double(d) / double(a));
}
q[i].t += t;
q[i].size = i;
}
double pre = -1.0;
for (int i = 0; i < n; i++) {
if ((q[i].t - pre) >= -1e-5) {
printf("%.10lf\n", q[i].t);
pre = q[i].t;
} else {
printf("%.10lf\n", pre);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef struct node {
double t;
double v;
} node;
int main() {
long int n;
double a, d;
cin >> n >> a >> d;
node n1;
n1.v = 0;
double t = 0.0, t1, dist, minim;
node ar[n];
for (int i = 0; i < n; i++) {
cin >> ar[i].t >> ar[i].v;
}
for (int i = 0; i < n; i++) {
t1 = (double)(ar[i].v) / a;
dist = ((t1 * t1) * a) / 2;
if (dist >= d) {
t = sqrt((2 * d) / a);
} else {
t = (d - dist) / (ar[i].v);
t = t + t1;
}
t = t + ar[i].t;
if (i == 0) minim = t;
if (minim > t)
t = minim;
else
minim = t;
printf("%0.6f \n", t);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double a, d;
cin >> n >> a >> d;
double res = 0;
while (n--) {
double t, v;
cin >> t >> v;
double tt = v / a;
double xx = d - a * tt * tt / 2.0;
if (xx < 0)
tt = sqrt(2 * d / a);
else
tt += xx / v;
res = max(res, tt + t);
printf("%.10f\n", res);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, d;
cin >> n >> a >> d;
double last = 0;
for (int i = 0; i < n; i++) {
int t, v;
cin >> t >> v;
double d1 = 0.5 * v * v / a;
double ans = t;
if (d1 > d) {
ans += sqrt(2.0 * d / a);
} else {
ans += (d - d1) / v + 1.0 * v / a;
}
if (i > 0 && ans < last) ans = last;
last = ans;
printf("%.12lf\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool sync_with_stdio(bool sync = true);
const int MaxN = 100000;
long long t[MaxN], v[MaxN];
const double eps = 1e-8;
double getTime(long long t, long long v, long long d, long long a) {
double dist = v * v / (2.0 * a);
double time = sqrt((2.0 * d) / a);
double res = 0;
if (dist - eps < d) {
time = sqrt((2.0 * dist) / a);
res = time + (d - dist) / v;
} else {
res = time;
}
return res + t;
}
int main() {
long long n, a, d;
scanf("%I64d%I64d%I64d", &n, &a, &d);
for (int i = 0; i < n; i++) scanf("%I64d%I64d", &t[i], &v[i]);
double nowTime = getTime(t[0], v[0], d, a);
cout.precision(20);
cout << nowTime << endl;
for (int i = 1; i < n; i++) {
double q = getTime(t[i], v[i], d, a);
if (q - eps < nowTime)
cout << nowTime << endl;
else {
nowTime = q;
cout << q << endl;
}
}
}
|
#include <bits/stdc++.h>
int n, a, d, t[1000000], v[1000000];
double p;
double max(double a, double b) { return a > b ? a : b; }
double T(int i) {
double _ = 0.5 * v[i] * v[i] / a;
if (_ <= d)
return (double)v[i] / a + (d - _) / v[i];
else
return sqrt(2 * d / (double)a);
}
int main(void) {
int i;
double _;
scanf("%d %d %d", &n, &a, &d);
for (i = 0; i < n; ++i) scanf("%d %d", t + i, v + i);
for (i = 0; i < n; ++i) {
_ = max(p, t[i] + T(i));
printf("%f\n", _);
p = _;
}
exit(0);
}
|
#include <bits/stdc++.h>
using namespace ::std;
int main(void) {
double n, a, d, t, v;
double dd, tt;
double front;
int ts;
cin >> n >> a >> d;
vector<double> times;
for (int i = 0; i < n; i++) {
cin >> t >> v;
tt = v / a;
dd = 0.5 * a * tt * tt;
if (dd > d + 1e-10) {
t += sqrt((2 * d) / a);
} else {
t += (d - dd) / v + tt;
}
if (!i) {
times.push_back(t);
front = t;
} else if (front > t) {
times.push_back(front);
} else {
times.push_back(t);
front = t;
}
}
ts = times.size();
for (int i = 0; i < ts; i++) {
printf("%.10f\n", times[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int d, n, a;
cin >> n >> a >> d;
int t[n], s[n];
float f[n];
for (int i = 0; i < n; i++) {
cin >> t[i] >> s[i];
double t1 = s[i] / (a * 1.0);
double d1 = 0.5 * t1 * t1 * a;
if (d1 >= d) {
double t3 = sqrt(2 * d / (a * 1.0));
f[i] = t[i] + t3;
} else {
double d2 = (d - d1 * 1.0) * 1.0;
double t2 = d2 / s[i];
f[i] = t2 + t1 + t[i];
}
}
printf("%.10f\n", f[0]);
for (int i = 1; i < n; i++) {
if (f[i] > f[i - 1])
printf("%.10f\n", f[i]);
else {
f[i] = f[i - 1];
printf("%.10f\n", f[i]);
}
}
return 0;
}
|
#include <bits/stdc++.h>
int main(void) {
const double eps = 1e-10;
int i, n, a, d, v, t;
double res1 = 0;
double res2 = 0;
scanf("%d %d %d", &n, &a, &d);
for (i = 0; i < n; i++) {
scanf("%d %d", &t, &v);
if (d + eps - (double)v * v / a / 2.0 < 0) {
res2 = t + sqrt(2.0 * d / a);
if (res1 + eps < res2) {
printf("%lf\n", res2);
res1 = res2;
} else
printf("%lf\n", res1);
} else {
res2 = (d - (double)v * v / a / 2.0) / v + (double)v / a + t;
if (res1 + eps < res2) {
printf("%lf\n", res2);
res1 = res2;
} else
printf("%lf\n", res1);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a, d;
vector<double> t, v;
int main() {
cin >> n >> a >> d;
for (int i = 0; i < n; i++) {
int tmp1, tmp2;
cin >> tmp1 >> tmp2;
t.push_back(tmp1);
v.push_back(tmp2);
}
for (int i = 0; i < n; i++) {
if (v[i] * v[i] < (double)2 * a * d) {
double tmp1 = (double)v[i] / a;
double tmp2 = (double)v[i] * v[i] / 2 / a;
t[i] += (tmp1 + (d - tmp2) / v[i]);
} else
t[i] += sqrt(double(2 * d) / (double)a);
}
for (int i = 0; i < n - 1; i++) {
if (t[i] > t[i + 1]) t[i + 1] = t[i];
}
for (int i = 0; i < n; i++) printf("%.10f\n", t[i]);
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int n, a, d, i;
double p = 0;
scanf("%d %d %d", &n, &a, &d);
for (i = 0; i < n; i++) {
int t, v;
scanf("%d %d", &t, &v);
if ((double)v * v / a / 2 < d) {
double x = (d - (double)v * v / a / 2) / v + (double)v / a;
if (t + x > p) {
printf("%.10lf\n", t + x);
p = t + x;
} else {
printf("%.10lf\n", p);
}
} else {
double x = sqrt(2.0 * d / a);
if (t + x > p) {
printf("%.10lf\n", t + x);
p = t + x;
} else {
printf("%.10lf\n", p);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-11;
const long long MOD = 1000000007;
const int N = 109;
void fast() { std::ios_base::sync_with_stdio(0); }
int main() {
double n, a, d, t, v;
scanf("%lf%lf%lf", &n, &a, &d);
double mx = -1;
for (int i = 0; i < n; i++) {
scanf("%lf%lf", &t, &v);
double ti = v / a;
double s = 0.5 * a * (ti * ti);
double dd = d - s;
if (dd < 0) {
double ans = (d * 2) / a;
ans = sqrt(ans) + t;
if (ans < mx)
printf("%.10lf\n", mx);
else
printf("%.10lf\n", ans);
mx = max(mx, ans);
continue;
}
double tt = dd / v;
tt += t + ti;
if (tt < mx)
printf("%.10lf\n", mx);
else
printf("%.10lf\n", tt);
mx = max(mx, tt);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long nChooseR(int n, int k);
int gcd(unsigned long long a, unsigned long long b);
void strCountsort(string& arr);
void intCountSort(vector<int>& arr);
long long n, m, a, r, l, x, y, d;
long long ans;
int primes[100005];
bool isPrime(int h) {
for (int i = 0; primes[i] * primes[i] <= h; i++)
if (h % primes[i] == 0) return 0;
return 1;
}
double power(double a, long long b) {
if (b == 1) return a;
if (b == 0) return 1.0;
double h = power(a, b / 2);
if (b % 2 == 0) return h * h;
return a * h * h;
}
int main() {
cout.precision(12);
string s;
cin >> n >> a >> d;
double o = 0.0;
long t, v;
while (n--) {
scanf("%d %d", &t, &v);
double time = min((double)v / a, sqrt(d * 2.0 / a)),
dis = d - (time * time / 2.0 * a);
o = max(o, t + time + dis / v);
cout << fixed << o << endl;
}
return 0;
}
long long nChooseR(int n, int k) {
if (k > n) return 0;
if (k * 2 > n) k = n - k;
if (k == 0) return 1;
long long result = n;
for (int i = 2; i <= k; ++i) {
result *= (n - i + 1);
result /= i;
}
return result;
}
int gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
void strCountsort(string& arr) {
string output = arr;
int max = *max_element(arr.begin(), arr.end());
int min = *min_element(arr.begin(), arr.end());
int range = max - min + 1;
vector<int> count(range);
int n = arr.size();
for (int i = 0; i < n; i++) count[arr[i] - min]++;
n = count.size();
for (int i = 1; i < n; i++) count[i] += count[i - 1];
n = arr.size();
for (int i = n - 1; i >= 0; i--) {
output[count[arr[i] - min] - 1] = arr[i];
count[arr[i] - min]--;
}
arr = output;
}
void intCountSort(vector<int>& arr) {
int max = *max_element(arr.begin(), arr.end());
int min = *min_element(arr.begin(), arr.end());
int range = max - min + 1;
vector<int> count(range), output(arr.size());
int n = arr.size();
for (int i = 0; i < n; i++) count[arr[i] - min]++;
n = count.size();
for (int i = 1; i < n; i++) count[i] += count[i - 1];
n = arr.size();
for (int i = n - 1; i >= 0; i--) {
output[count[arr[i] - min] - 1] = arr[i];
count[arr[i] - min]--;
}
for (int i = 0; i < n; i++) arr[i] = output[i];
}
|
#include <bits/stdc++.h>
using namespace std;
pair<int, int> t[1000001];
double count_time(double a, double v, double h) {
double s = v * v / (2 * a);
if (s + 1e-7 >= h) return sqrt(2 * h / a);
return (v / (a * 2) + h / v);
}
int main() {
cout.setf(ios::fixed);
cout.precision(6);
int n;
double a, d;
cin >> n >> a >> d;
for (int i = 0; i < (n); i++) cin >> t[i].first >> t[i].second;
double time = t[0].first + count_time(a, t[0].second, d);
cout << time << '\n';
for (int i = 1; i <= (n - 1); i++) {
double timec = t[i].first + count_time(a, t[i].second, d);
if (timec + 1e-7 >= time) {
time = timec;
cout << timec << '\n';
} else
cout << time << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int n, a, d;
std::scanf("%d%d%d", &n, &a, &d);
double current_best = .0;
for (int i = 0; i < n; i++) {
int t, v;
std::scanf("%d%d", &t, &v);
double ttfs = (double)v / a, dist_accelerating = ttfs * v / 2,
reaches_end = t;
if (dist_accelerating > (double)d) {
reaches_end += std::sqrt((double)2 * d / a);
} else {
reaches_end += ttfs + (d - dist_accelerating) / v;
}
current_best = std::max(current_best, reaches_end);
std::printf("%lf\n", current_best);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int n, a, d, t, v;
double p, s, m = 0;
scanf("%d%d%d", &n, &a, &d);
for (int i = 0; i < n; i++) {
scanf("%d%d", &t, &v);
p = 1.0 * v / a;
s = v * p * 0.5;
if (s >= d)
p = sqrt(2.0 * d / a) + t;
else {
s = d - s;
p += s / v;
p += t;
}
if (p < m)
printf("%lf\n", m);
else {
printf("%lf\n", p);
m = p;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
int n;
double a, d;
cin >> n >> a >> d;
int ti, si;
double last = 0;
cout << fixed << setprecision(8);
for (int i = 0; i < n; i++) {
cin >> ti >> si;
double dd = (long long)si * (long long)si / (2 * a);
double time_taken;
if (d > dd)
time_taken = si / a + (d - dd) / (double)si;
else
time_taken = sqrt(2 * d / a);
if (time_taken + ti > last) {
cout << time_taken + ti << "\n";
last = time_taken + ti;
} else
cout << last << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long nChooseR(int n, int k);
int gcd(unsigned long long a, unsigned long long b);
void strCountsort(string& arr);
void intCountSort(vector<int>& arr);
long long n, m, a, r, l, x, y, d;
long long ans;
int primes[100005];
bool isPrime(int h) {
for (int i = 0; primes[i] * primes[i] <= h; i++)
if (h % primes[i] == 0) return 0;
return 1;
}
double power(double a, long long b) {
if (b == 1) return a;
if (b == 0) return 1.0;
double h = power(a, b / 2);
if (b % 2 == 0) return h * h;
return a * h * h;
}
int main() {
cout.precision(12);
string s;
cin >> n >> a >> d;
double o = 0.0;
long t, v;
while (n--) {
scanf("%d %d", &t, &v);
double time = min((double)v / a, sqrt(d * 2.0 / a)),
dis = d - (time * time / 2.0 * a);
o = max(o, t + time + dis / v);
printf("%.6f\n", o);
}
return 0;
}
long long nChooseR(int n, int k) {
if (k > n) return 0;
if (k * 2 > n) k = n - k;
if (k == 0) return 1;
long long result = n;
for (int i = 2; i <= k; ++i) {
result *= (n - i + 1);
result /= i;
}
return result;
}
int gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
void strCountsort(string& arr) {
string output = arr;
int max = *max_element(arr.begin(), arr.end());
int min = *min_element(arr.begin(), arr.end());
int range = max - min + 1;
vector<int> count(range);
int n = arr.size();
for (int i = 0; i < n; i++) count[arr[i] - min]++;
n = count.size();
for (int i = 1; i < n; i++) count[i] += count[i - 1];
n = arr.size();
for (int i = n - 1; i >= 0; i--) {
output[count[arr[i] - min] - 1] = arr[i];
count[arr[i] - min]--;
}
arr = output;
}
void intCountSort(vector<int>& arr) {
int max = *max_element(arr.begin(), arr.end());
int min = *min_element(arr.begin(), arr.end());
int range = max - min + 1;
vector<int> count(range), output(arr.size());
int n = arr.size();
for (int i = 0; i < n; i++) count[arr[i] - min]++;
n = count.size();
for (int i = 1; i < n; i++) count[i] += count[i - 1];
n = arr.size();
for (int i = n - 1; i >= 0; i--) {
output[count[arr[i] - min] - 1] = arr[i];
count[arr[i] - min]--;
}
for (int i = 0; i < n; i++) arr[i] = output[i];
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a, d;
double ans[N], as[N];
struct rec {
int t, v, c;
} bus[N];
int cmp(const rec &a, const rec &b) {
if (a.t == b.t) return a.v > b.v;
return a.t < b.t;
}
double calc(int k) {
double t1 = bus[k].v / (a * 1.0), d1 = (double)a * t1 * t1 / 2;
if (d1 >= d) return sqrt(2 * d * 1.0 / (a * 1.0));
double t2 = (1.0 * d - d1) / (bus[k].v * 1.0);
return t1 + t2;
}
int main() {
cin >> n >> a >> d;
for (int i = 1; i <= n; i++) cin >> bus[i].t >> bus[i].v, bus[i].c = i;
sort(bus + 1, bus + 1 + n, cmp);
ans[0] = -1e20;
for (int i = 1; i <= n; i++) {
double tmp = calc(i);
if (bus[i].t + tmp < ans[i - 1])
ans[i] = ans[i - 1];
else
ans[i] = tmp + bus[i].t;
}
for (int i = 1; i <= n; i++) as[bus[i].c] = ans[i];
for (int i = 1; i <= n; i++) printf("%.10f\n", as[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double a, d;
scanf("%d%lf%lf", &n, &a, &d);
double pre = 0;
for (int i = 0; i < n; i++) {
double b, v;
scanf("%lf%lf", &b, &v);
double t = v / a;
double l = v * t / 2;
if (l > d)
t = sqrt(2 * d / a);
else
t += (d - l) / v;
t += b;
pre = max(pre, t);
printf("%.10f\n", pre);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long double acc;
long double d;
long double getTime(double speed, double start_time) {
long double t = speed * 1.0 / acc;
long double dist = 0.5 * acc * t * t;
long double ans;
if (dist >= d) {
ans = sqrt(2 * d / acc);
} else {
ans = (long double)t + (d - dist) * 1.0 / speed;
}
return ans + (long double)start_time;
}
int main() {
int n;
int i;
cin >> n >> acc >> d;
int cars[1000000][2];
for (i = 0; i < n; ++i) {
scanf("%d%d", &cars[i][0], &cars[i][1]);
}
long double prev = 0;
long double temp;
cout.precision(10);
for (i = 0; i < n; ++i) {
temp = getTime(cars[i][1], cars[i][0]);
if (temp < prev)
cout << prev << endl;
else {
cout << temp << endl;
prev = temp;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff, M = (int)(2e3 + 100);
int a, d, n;
int main(void) {
while (~scanf("%d%d%d", &n, &a, &d)) {
double pre = double(0);
while (n--) {
double anst;
double x, y;
scanf("%lf%lf", &x, &y);
double t = (y / a);
if (t * y / 2 > d)
anst = sqrt(2 * d / double(a));
else {
anst = t + (d - t * y / 2) / y;
}
if (anst + x < pre)
printf("%.10f\n", pre);
else {
pre = anst + x;
printf("%.10f\n", pre = anst + x);
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
struct point {
double t, v;
} p[100005];
double c[100005];
int main() {
double a, d;
int n;
while (scanf("%d%lf%lf", &n, &a, &d) != EOF) {
memset(c, 0, sizeof(c));
for (int i = 1; i <= n; i++) {
scanf("%lf%lf", &p[i].t, &p[i].v);
double t = p[i].v / a;
double s = a * t * t / 2;
if (s >= d)
c[i] = (sqrt(2 * d / a)) + p[i].t;
else
c[i] = t + (d - s) / p[i].v + p[i].t;
}
printf("%lf\n", c[1]);
int flag = 0;
double ans = c[1];
for (int i = 2; i <= n; i++) {
if (c[i] > ans)
printf("%lf\n", c[i]), ans = c[i];
else {
printf("%lf\n", ans);
}
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool up_max(T& a, const T& b) {
return b > a ? a = b, 1 : 0;
}
template <class T>
bool up_min(T& a, const T& b) {
return b < a ? a = b, 1 : 0;
}
struct Node {
int id;
double t, v, T;
bool operator<(Node b) const { return t < b.t || (t == b.t && v > b.v); }
} a[100020];
int n;
double A, D;
int sgn(double x) { return (x > 1e-10) - (x < -1e-10); }
double gettime(int i) {
double tt = a[i].v / A;
double ss = 0.5 * A * tt * tt;
if (sgn(ss - D) < 0) {
return tt + ((D - ss) / a[i].v);
} else
return sqrt(D * 2.0 / A);
}
double aa[100020];
int main() {
while (cin >> n >> A >> D) {
int i;
for (i = 1; i <= n; ++i) {
scanf("%lf%lf", &a[i].t, &a[i].v);
a[i].id = i;
}
sort(a + 1, a + 1 + n);
a[1].T = gettime(1) + a[1].t;
for (i = 2; i <= n; ++i) {
a[i].T = gettime(i) + a[i].t;
if (sgn(a[i - 1].T - a[i].T) > 0) a[i].T = a[i - 1].T;
}
for (i = 1; i <= n; ++i) aa[a[i].id] = a[i].T;
for (i = 1; i <= n; ++i) printf("%.8lf\n", aa[i]);
}
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char *sdbg, TH h) {
cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char *sdbg, TH h, TA... t) {
while (*sdbg != ',') {
cerr << *sdbg++;
}
cerr << "=" << h << ",";
_dbg(sdbg + 1, t...);
}
template <class T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
return a * b / gcd(a, b);
}
vector<string> split(string s) {
istringstream buf(s);
istream_iterator<string> beg(buf), end;
vector<string> list(beg, end);
return list;
}
bool isvowel(char c) {
string s = "aeiouAEIOU";
if (find(s.begin(), s.end(), c) != s.end()) return true;
return false;
}
vector<long long> sieve(long long n) {
vector<bool> prime(n + 1, true);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= n; i++) {
if (prime[i])
for (int j = i * i; j <= n; j += i) {
prime[j] = 0;
}
}
vector<long long> p;
for (int i = 2; i <= prime.size(); i++)
if (prime[i]) p.push_back(i);
return p;
}
bool isprime(int n) {
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true && (n != 1);
}
int ncr(long long n, long long r) {
long long C[r + 1];
memset(C, 0, sizeof(C));
C[0] = 1;
for (long long i = 1; i <= n; i++) {
for (long long j = min(i, r); j > 0; j--)
C[j] = (C[j] + C[j - 1]) % 1000000007;
}
return C[r];
}
bool special(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == ' ') continue;
if (s[i] == '#')
return true;
else
return false;
}
return false;
}
void solve() {
cout << fixed << setprecision(10);
int n, d;
double a;
cin >> n >> a >> d;
vector<pair<int, int> > v(n);
double max_ans = 0;
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
double s1 = 1.0 * v[i].second * v[i].second / (2 * a);
double t = v[i].first;
if (d < s1) {
t += sqrt(2 * d / a);
} else {
t += 1.0 * v[i].second / a + (d - s1) / v[i].second;
}
max_ans = max(t, max_ans);
cout << max_ans << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
int n, a, d;
cin >> n >> a >> d;
vector<int> t(n), v(n);
for (int i = 0; i < n; i++) {
cin >> t[i] >> v[i];
}
double maxTime = 0;
for (int i = 0; i < n; i++) {
double time = t[i];
double d1 = 0.5 * v[i] * v[i] / a;
if (d1 > d) {
double vMax = sqrt(2. * a * d);
time += vMax / a;
} else {
time += 1. * v[i] / a;
double dRem = d - d1;
time += dRem / v[i];
}
maxTime = max(time, maxTime);
cout << maxTime << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
const double eps = 1e-6;
int n;
double a, dd;
double vv;
double tt;
double deallen(double vc, double maxv, double t, double &tv) {
double temp = (maxv - vc) / a;
if (t < temp) {
tv = a * t + vc;
return 0.5 * a * t * t + vc * t;
}
tv = maxv;
return 0.5 * temp * (maxv - vc) + (t - temp) * maxv;
}
double dealtime(double vc, double maxv, double dd, double &tv) {
double temp = (maxv - vc) * (maxv - vc) / a / 2;
if (temp > dd) {
tv = vc + sqrt(2 * a * dd);
return (tv - vc) / a;
}
tv = maxv;
return (dd - temp) / maxv + (maxv - vc) / a;
}
int main() {
while (scanf("%d%lf%lf", &n, &a, &dd) != EOF) {
int i;
double last = -1000000000;
for (i = 0; i < n; i++) {
scanf("%lf%lf", &tt, &vv);
double tv;
double temp = dealtime(0, vv, dd, tv);
if (temp + tt > last) {
last = temp + tt;
printf("%.6lf\n", last);
} else {
printf("%6lf\n", last);
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
double F[1002000 * 2];
int n;
double a, d;
inline void upd(int x, const double& t) {
for (; x <= 1002000; x += ((x) & (-(x)))) F[x] = max(F[x], t);
}
inline double Max(int x) {
double M = 0;
for (; x; x -= ((x) & (-(x)))) M = max(F[x], M);
return M;
}
struct Node {
double V, t;
int id, T;
bool operator<(const Node& X) const { return T < X.T; }
} s[1002000];
inline bool cmp(Node a, Node b) { return a.id < b.id; }
int main() {
scanf("%d%lf%lf", &n, &a, &d);
for (int i = 0; i < n; ++i)
scanf("%d%lf", &s[i].T, &s[i].V), s[i].id = i + 1, ++s[i].T;
sort(s, s + n);
for (int i = 0; i < n; ++i) {
double t1 = s[i].V / a;
double t;
if (a * t1 * t1 / 2 > d)
t = sqrt(2 * d / a);
else
t = t1 + (d - a * t1 * t1 / 2) / s[i].V;
t += s[i].T;
t = max(t, Max(s[i].T));
s[i].t = t - 1;
upd(s[i].T, t);
}
sort(s, s + n, cmp);
for (int i = 0; i < n; ++i) printf("%.14f\n", s[i].t);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char *sdbg, TH h) {
cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char *sdbg, TH h, TA... t) {
while (*sdbg != ',') {
cerr << *sdbg++;
}
cerr << "=" << h << ",";
_dbg(sdbg + 1, t...);
}
template <class T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
return a * b / gcd(a, b);
}
vector<string> split(string s) {
istringstream buf(s);
istream_iterator<string> beg(buf), end;
vector<string> list(beg, end);
return list;
}
bool isvowel(char c) {
string s = "aeiouAEIOU";
if (find(s.begin(), s.end(), c) != s.end()) return true;
return false;
}
vector<long long> sieve(long long n) {
vector<bool> prime(n + 1, true);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= n; i++) {
if (prime[i])
for (int j = i * i; j <= n; j += i) {
prime[j] = 0;
}
}
vector<long long> p;
for (int i = 2; i <= prime.size(); i++)
if (prime[i]) p.push_back(i);
return p;
}
bool isprime(int n) {
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true && (n != 1);
}
int ncr(long long n, long long r) {
long long C[r + 1];
memset(C, 0, sizeof(C));
C[0] = 1;
for (long long i = 1; i <= n; i++) {
for (long long j = min(i, r); j > 0; j--)
C[j] = (C[j] + C[j - 1]) % 1000000007;
}
return C[r];
}
bool special(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == ' ') continue;
if (s[i] == '#')
return true;
else
return false;
}
return false;
}
void solve() {
cout << fixed << setprecision(10);
double n, a, d;
cin >> n >> a >> d;
vector<pair<int, int> > v(n);
double max_ans = 0;
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
double s1 = 1.0 * v[i].second * v[i].second / (2 * a);
double t = v[i].first;
if (d < s1)
t += sqrt(2 * d / a);
else
t += 1.0 * v[i].second / a + (d - s1) / v[i].second;
if (t > max_ans) max_ans = t;
cout << max_ans << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
int n, a, d;
int main(void) {
int i;
int tmpt, tmpv;
double time = 0;
double beforetime;
double maxvtime;
scanf("%d %d %d", &n, &a, &d);
for (i = 0; i < n; i++) {
scanf("%d %d", &tmpt, &tmpv);
beforetime = time;
maxvtime = (double)tmpv / (double)a / 2.0;
if (maxvtime * (double)tmpv <= (double)d)
time =
(((double)tmpv / (double)a) +
((double)d - ((((double)tmpv / (double)a) * (double)tmpv) * 0.5)) /
(double)tmpv) +
(double)tmpt;
else
time = sqrt((2.0 * d) / a) + (double)tmpt;
if (i != 0) {
if (time < beforetime) time = beforetime;
}
printf("%.10lf\n", time);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n, a, d;
int main() {
scanf("%d %d %d", &n, &a, &d);
double ant = 0.0;
for (int i = 0; i < n; i++) {
int t, v;
scanf("%d %d", &t, &v);
double mruvt = (double)v / (double)a;
double distali = (mruvt * mruvt * (double)a) / 2.0;
if (distali >= d) {
double tot = t + sqrt((2.0 * (double)d) / (double)a);
tot = max(tot, ant);
printf("%.10lf\n", tot);
ant = tot;
continue;
}
double nd = d - distali;
double tot = t + mruvt;
tot += nd / (double)v;
tot = max(tot, ant);
printf("%.10lf\n", tot);
ant = tot;
continue;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int n;
double t, v, c, Max, a, d;
int main() {
scanf("%d%lf%lf", &n, &a, &d);
for (int i = 1; i <= n; i++) {
scanf("%lf%lf", &t, &v);
c = t;
if (v * v / (2 * a) < d)
c += (d - v * v / (2 * a)) / v + v / a;
else
c += sqrt(2 * d / a);
if (Max > c)
printf("%.10lf", Max);
else
printf("%.10lf", c), Max = c;
puts("");
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
std::cout << std::setprecision(9);
std::cout << std::fixed;
long long n, a, d, i;
cin >> n >> a >> d;
long double b[n];
for (i = 0; i < n; i++) {
long long x, v;
cin >> x >> v;
long double p = (long double)v * (long double)v /
((long double)2 * (long double)a),
ans = 0;
if (d > p) {
ans = (long double)v / (long double)a +
((long double)d - p) / (long double)v;
} else
ans = sqrt(((long double)2 * (long double)d) / (long double)a);
b[i] = ans + (long double)x;
}
for (i = 1; i < n; i++) {
if (b[i] < b[i - 1]) b[i] = b[i - 1];
}
for (i = 0; i < n; i++) cout << b[i] << endl;
}
|
#include <bits/stdc++.h>
using namespace std;
double calc(int d, int a, int v) {
double t = 1.0 * v / a;
if (d < 0.5 * v * t)
return sqrt(2.0 * d / a);
else
return t + (d - 0.5 * v * t) / v;
}
int main() {
int n, a, d;
cin >> n >> a >> d;
double mx = 0;
while (n--) {
int s, v;
cin >> s >> v;
double val = max(mx, s + calc(d, a, v));
mx = max(mx, val);
printf("%.10lf\n", val);
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double a, d;
int n;
cin >> n >> a >> d;
double tc = 0.0f, tm = 0.0f;
for (int i = 0; i < n; i++) {
double t, v, d1, t1;
cin >> t >> v;
d1 = v * v / (2.0 * a);
tc = (d1 > d) ? t + sqrt(2.0 * d / a) : t + (d - d1) / v + v / a;
if (tc < tm)
tc = tm;
else
tm = tc;
printf("%.8f\n", tc);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a, d;
int n;
double tCome(double start, double v) {
double tAcc = v / a;
if (((tAcc) * (tAcc)) * a / 2 > d) {
return sqrt(2 * d / a) + start;
} else {
double ans = ((d - ((tAcc) * (tAcc)) * a / 2) / v) + tAcc;
return ans + start;
}
}
int main() {
cin.sync_with_stdio(false);
cout.sync_with_stdio(false);
cin >> n >> a >> d;
double tMax = 0, l, r;
for (int i = 0; i < n; i++) {
cin >> l >> r;
tMax = max(tMax, tCome(l, r));
printf("%.4f\n", tMax);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, d;
cin >> n >> a >> d;
double last = 0.00;
int t, v;
while (n--) {
cin >> t >> v;
double tt;
if (v * 1.00 / a * v > 2.00 * d) {
tt = sqrt(2 * d * 1.00 / a);
} else {
tt = d * 1.00 / v - v * 0.5 / a + v * 1.00 / a;
}
if (tt + t > last) last = tt + t;
printf("%.10lf\n", last);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
int N;
double A, D;
cin >> N >> A >> D;
double prev = 0.0;
cout << fixed;
cout.precision(9);
for (int i = 1; i <= N; i++) {
double t, v;
cin >> t;
cin >> v;
double t_stop = sqrt(2.0 * D / A);
double t_max = v / A;
double t_ans = t;
if (t_stop < t_max)
t_ans += t_stop;
else
t_ans += t_max + D / v - v / (2.0 * A);
t_ans = max(prev, t_ans);
cout << t_ans << endl;
prev = t_ans;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argv, char* argc[]) {
long long n;
double a, d;
cin >> n >> a >> d;
vector<vector<double> > tram(n, vector<double>(3, 0));
for (long long i = 0; i < n; i++) {
cin >> tram[i][0] >> tram[i][1];
}
for (long long i = 0; i < n; i++) {
double t = tram[i][1] / a;
double s = a * pow(t, 2.0) / 2;
if (s > d) {
t = sqrt(2 * d / a);
} else {
t += (d - s) / tram[i][1];
}
t += tram[i][0];
if (i >= 1 && t <= tram[i - 1][2]) {
tram[i][2] = tram[i - 1][2];
} else {
tram[i][2] = t;
}
}
for (long long i = 0; i < tram.size(); i++) {
printf("%.4lf\n", tram[i][2]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
int n, a, d;
cin >> n >> a >> d;
int t, v;
double T, P = 0, D;
while (n--) {
cin >> t >> v;
T = 1.0 * v / a;
if (T * v <= 2 * d) {
D = (1.0 * d - T * v * 0.5) / v;
T = T + D;
} else {
T = sqrt(2.0 * d / a);
}
T += t;
if (T < P) T = P;
printf("%.7f\n", T);
P = T;
}
return EXIT_SUCCESS;
}
|
#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
if (a > b)
return a;
else
return b;
}
long long min(long long a, long long b) {
if (a < b)
return a;
else
return b;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int n;
double ans, a, d, t, v;
int main() {
scanf("%d%lf%lf", &n, &a, &d);
while (n--) {
scanf("%lf%lf", &t, &v);
if (d > (v * v) / (2 * a))
t += (v / a) + (d / v) - (v / (2 * a));
else
t += sqrt(2 * d / a);
ans = max(ans, t);
printf("%.6lf\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
double a, d;
cin >> n >> a >> d;
double t, v, buf;
double time = 0, now;
for (int i = 0; i < n; i++) {
cin >> t >> v;
buf = v * v / (2 * a);
if (buf > d) {
now = t + sqrt(d * 2.0 / a);
} else {
now = t + v / a + (d - buf) / v;
}
time = ((time) < (now) ? (now) : (time));
cout << time << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int INF = 2e9 + 7;
const double EPS = 1e-12;
const int P = 239017;
const int MOD = 1e9 + 7;
int fx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int fy[] = {0, 0, 1, -1, -1, 1, -1, 1};
int n;
double a, d, v, t, s;
double ans[N];
int main() {
cin >> n >> a >> d;
for (int i = 0; i < n; i++) {
scanf("%lf%lf", &ans[i], &v);
t = v / a;
s = a * t * t / 2.0;
if (s > d) {
ans[i] += sqrt(2.0 * d / a);
ans[i] = max(ans[i], ans[i - 1]);
printf("%.10lf\n", ans[i]);
continue;
}
ans[i] += t;
s = d - s;
ans[i] += s / v;
ans[i] = max(ans[i], ans[i - 1]);
printf("%.10lf\n", ans[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
long long n, a, d, v, t;
cin >> n >> a >> d;
long double pre = -1000000.0;
for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
i += 1 - 2 * ((0) > (n))) {
cin >> t >> v;
long double s1 = (1.0 * v * v) / (1.0 * 2 * a);
long double req = t * 1.0;
if (s1 >= d) {
req += sqrt(2 * d / (1.0 * a));
} else {
req += sqrt(2 * s1 / (1.0 * a));
req += 1.0 * (d - s1) / (1.0 * v);
}
req = max(pre, req);
cout << fixed << setprecision(10) << req << "\n";
pre = req;
}
return 0;
}
|
#include <bits/stdc++.h>
int main(int argc, char* argv[]) {
int n, a, d, i, t1, t2, v1, v2;
double time1, time2;
scanf("%d%d%d", &n, &a, &d);
scanf("%d%d", &t1, &v1);
if (((double(v1) / a) * (double(v1) / a) * a / 2.0) < d)
time1 = double(v1) / a + t1 + (d - (double(v1) * v1 / a) / 2.0) / v1;
else
time1 = sqrt(2 * double(d) / a) + t1;
printf("%.10lf\n", time1);
for (i = 1; i < n; i++) {
scanf("%d%d", &t2, &v2);
if (((double(v2) / a) * (double(v2) / a) * a / 2.0) < d)
time2 = double(v2) / a + t2 + (d - (double(v2) * v2 / a) / 2.0) / v2;
else
time2 = sqrt(2 * double(d) / a) + t2;
if (time2 > time1) time1 = time2;
printf("%.10lf\n", time1);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double a, d;
double pre(double v) {
if (d >= (v * v) / (2.0 * a)) {
double x = v / a;
double y = d - ((v * v) / (2.0 * a));
double out = x + (y / (v));
return out;
} else {
double out = sqrt((2.0 * d) / a);
return out;
}
}
int main() {
int n;
cin >> n >> a >> d;
double arr[n][2];
double time[n];
for (int i = 0; i < n; i++) {
scanf("%lf%lf", &arr[i][0], &arr[i][1]);
double x = pre(arr[i][1]);
time[i] = x + arr[i][0];
if (i != 0 && time[i] < time[i - 1]) {
time[i] = time[i - 1];
}
printf("%.6f\n", time[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
int n;
double a, d, t[N], v[N];
int main() {
scanf("%d%lf%lf", &n, &a, &d);
double maxt = 0;
for (int i = 1; i <= n; i++) {
scanf("%lf%lf", &t[i], &v[i]);
double t1 = v[i] / a;
double d1 = 0.5 * a * t1 * t1;
double d2 = d - d1;
double t2, t3;
if (d2 < 0) {
t3 = sqrt(2 * d / a);
t3 = t3 + t[i];
} else {
t2 = d2 / v[i];
t3 = t1 + t2 + t[i];
}
if (t3 > maxt) {
cout << t3 << endl;
maxt = t3;
} else {
cout << maxt << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef char* cstr;
const int oo = (~0u) >> 1;
const long long int ooll = (~0ull) >> 1;
const double inf = 1e100;
const double eps = 1e-8;
const double pi = acos(-1.0);
template <typename type>
inline bool cmax(type& a, const type& b) {
return a < b ? a = b, true : false;
}
template <typename type>
inline bool cmin(type& a, const type& b) {
return a > b ? a = b, true : false;
}
template <typename type>
inline int sgn(const type& first) {
return (first > 0) - (first < 0);
}
template <>
inline int sgn(const double& first) {
return (first > +eps) - (first < -eps);
}
template <typename type>
void inc(vector<type>& st, int first, type inc) {
while (first < ((int)(st).size()))
st[first] += inc, first += (first) & (-(first));
}
template <typename type>
type sum(vector<type>& st, int first) {
type s = 0;
while (first > 0) s += st[first], first -= (first) & (-(first));
return s;
}
int main() {
int n;
double a, d;
cin >> n >> a >> d;
double t1 = sqrt(d / (0.5 * a));
vector<double> t(n), v(n), ans(n);
for (int i = 0; i < (n); ++i) {
cin >> t[i] >> v[i];
if (t1 * a > v[i]) {
double t2 = v[i] / a;
double d1 = d - 0.5 * a * (t2) * (t2);
double t3 = d1 / v[i];
ans[i] = t[i] + t2 + t3;
} else
ans[i] = t[i] + t1;
}
for (int i = (1); i <= (n - 1); ++i) cmax(ans[i], ans[i - 1]);
for (int i = 0; i < (n); ++i) printf("%.50f\n", ans[i]);
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
double n, a, d, t, v;
cin >> n >> a >> d;
double prevTime = 0.0;
for (long long i = 0; i < n; i++) {
cin >> t >> v;
double s = (v * v) / (2.0 * a);
double time;
if (s > d) {
time = sqrt(2.0 * d / a);
} else {
time = (v / a) + (d - s) / v;
}
prevTime = max(t + time, prevTime);
printf("%.6lf\n", prevTime);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct t_v {
float t, v;
};
int mycomp(t_v a, t_v b) { return (a.t < b.t); }
int main() {
int n;
float a, d;
scanf("%d %f %f", &n, &a, &d);
t_v tv[n];
for (int i = 0; i < n; i++) {
scanf("%f %f", &tv[i].t, &tv[i].v);
}
sort(tv, tv + n, mycomp);
for (int i = 0; i < n; i++) {
float t1 = 0, t2 = 0, d1 = 0;
t1 = tv[i].v / a;
d1 = d - a * t1 * t1 / 2;
if (d1 > 0)
t2 = d1 / tv[i].v;
else {
t1 = sqrt((d * 2) / a);
}
if (i == 0)
tv[i].t += t1 + t2;
else if (tv[i].t + t1 + t2 < tv[i - 1].t)
tv[i].t = tv[i - 1].t;
else
tv[i].t += t1 + t2;
}
for (int i = 0; i < n; i++) printf("\n%f", tv[i].t);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int PINF = numeric_limits<int>::max();
const int NINF = numeric_limits<int>::min();
const long long M = 1E9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
long long n, a, d;
cin >> n >> a >> d;
vector<long long> t(n + 1), v(n + 1);
vector<double> dp(n + 1);
for (int i = 1; i <= n; i++) {
cin >> t[i] >> v[i];
}
dp[0] = 0;
for (int i = 1; i <= n; i++) {
double finish_time;
if (v[i] > sqrt(2 * a * d)) {
finish_time = t[i] + sqrt(2.0 * d / (double)a);
} else {
double accelerating_time = v[i] / (double)a;
double constant_time = d / (double)v[i] - v[i] / (2.0 * a);
finish_time = t[i] + accelerating_time + constant_time;
}
dp[i] = max(dp[i - 1], finish_time);
printf("%0.10f\n", dp[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int n, a, d;
cin >> n >> a >> d;
vector<pair<long long int, long long int> > v(n);
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
}
vector<double> ans(n);
double pre = 0;
for (int i = 0; i < n; i++) {
double now;
long long int mv = v[i].second;
if (d * 2 * a >= mv * mv) {
now =
((double)d - ((double)mv / 2 / (double)a * (double)mv)) / (double)mv +
(double)mv / (double)a;
} else {
now = sqrt(2 * (double)d / (double)a);
}
now += (double)v[i].first;
if (pre > now) {
ans[i] = pre;
} else {
ans[i] = now;
}
pre = ans[i];
}
for (int i = 0; i < n; i++) printf("%.10lf\n", ans[i]);
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double n, d, a, v, k, ma;
int main() {
cin >> n >> a >> d;
for (int i = 0; i < n; i++) {
cin >> k >> v;
if ((v / a) * (v / a) / 2.0 * a >= d) {
ma = max(sqrt(d / a * 2.0) + k, ma);
cout << fixed << setprecision((10)) << ma << endl;
} else {
ma = max((d + a * (v / a) * (v / a) / 2) / v + k, ma);
cout << fixed << setprecision((10)) << ma << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int const MAX = 100005;
double m[MAX];
double n, a, d;
void cal(int i, double t, double v) {
double tmp, r, s;
tmp = v / a;
s = a * tmp * tmp / 2;
if (s > d)
r = sqrt(d * 2 / a) + t;
else
r = t + tmp + (d - s) / v;
m[i] = r;
}
int main() {
int i, j, tmp;
double t, v;
while (cin >> n >> a >> d) {
memset(m, 0, sizeof m);
for (i = 0; i < n; i++) {
cin >> t >> v;
cal(i, t, v);
}
for (i = 1; i < n; i++)
if (m[i - 1] > m[i]) m[i] = m[i - 1];
for (i = 0; i < n; i++) printf("%.10lf\n", m[i]);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
double t, s, y, x, a, d, v, U[100000];
int n, i, H[100000][2];
int main() {
cin >> n >> a >> d;
for (i = 0; i < n; i++) cin >> H[i][0] >> H[i][1];
for (i = 0; i < n; i++) {
t = H[i][0];
v = H[i][1];
y = v / a;
s = v * y / 2;
if (d >= s) {
x = (d - s) / v;
U[i] = x + y + t;
} else {
x = 2 * d / a;
U[i] = sqrt(x) + t;
}
}
for (i = 1; i < n; i++)
if (U[i] < U[i - 1]) U[i] = U[i - 1];
for (i = 0; i < n; i++) cout << U[i] << endl;
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char *sdbg, TH h) {
cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char *sdbg, TH h, TA... t) {
while (*sdbg != ',') {
cerr << *sdbg++;
}
cerr << "=" << h << ",";
_dbg(sdbg + 1, t...);
}
template <class T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
return a * b / gcd(a, b);
}
vector<string> split(string s) {
istringstream buf(s);
istream_iterator<string> beg(buf), end;
vector<string> list(beg, end);
return list;
}
bool isvowel(char c) {
string s = "aeiouAEIOU";
if (find(s.begin(), s.end(), c) != s.end()) return true;
return false;
}
vector<long long> sieve(long long n) {
vector<bool> prime(n + 1, true);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= n; i++) {
if (prime[i])
for (int j = i * i; j <= n; j += i) {
prime[j] = 0;
}
}
vector<long long> p;
for (int i = 2; i <= prime.size(); i++)
if (prime[i]) p.push_back(i);
return p;
}
bool isprime(int n) {
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true && (n != 1);
}
int ncr(long long n, long long r) {
long long C[r + 1];
memset(C, 0, sizeof(C));
C[0] = 1;
for (long long i = 1; i <= n; i++) {
for (long long j = min(i, r); j > 0; j--)
C[j] = (C[j] + C[j - 1]) % 1000000007;
}
return C[r];
}
bool special(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == ' ') continue;
if (s[i] == '#')
return true;
else
return false;
}
return false;
}
void solve() {
cout << fixed << setprecision(10);
int n, d;
int a;
cin >> n >> a >> d;
vector<pair<int, int> > v(n);
double max_ans = 0;
for (int i = 0; i < n; i++) {
cin >> v[i].first >> v[i].second;
double s1 = 1.0 * v[i].second * v[i].second / (2 * a);
double t = v[i].first;
if (d < s1) {
t += sqrt(2.0 * d / a);
} else {
t += 1.0 * v[i].second / a + 1.0 * (d - s1) / v[i].second;
}
max_ans = max(t, max_ans);
cout << max_ans << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, a, d;
cin >> n >> a >> d;
double time;
double lastTime = 0;
int ti;
int vm;
for (int32_t i = (0); i < int32_t(n); ++i) {
cin >> ti >> vm;
int vi = 0;
double time = vm * 1.0 / a;
if (((0 + vm) * 1.0 / 2 * time) < d)
time = time + (d - ((0 + vm) * 1.0 / 2 * time)) * 1.0 / vm;
else
time = sqrt(d * 2.0 / a);
time += ti;
if (time < lastTime) {
time = lastTime;
}
printf("%.6f\n", time);
lastTime = time;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
double n, a, d;
int main() {
cin >> n >> a >> d;
int x, y;
double t, p, last;
for (int i = 0; i < n; ++i) {
scanf("%d%d", &x, &y);
t = sqrt(2 * d / a);
if (a * t >= y) {
t = y / a;
p = d - a * t * t / 2;
t += p / y;
}
t += x;
if (t <= last) t = last;
printf("%lf\n", t);
last = t;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename TH>
void _dbg(const char *sdbg, TH h) {
cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char *sdbg, TH h, TA... t) {
while (*sdbg != ',') {
cerr << *sdbg++;
}
cerr << "=" << h << ",";
_dbg(sdbg + 1, t...);
}
template <class T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
return a * b / gcd(a, b);
}
vector<string> split(string s) {
istringstream buf(s);
istream_iterator<string> beg(buf), end;
vector<string> list(beg, end);
return list;
}
bool isvowel(char c) {
string s = "aeiouAEIOU";
if (find(s.begin(), s.end(), c) != s.end()) return true;
return false;
}
vector<long long> sieve(long long n) {
vector<bool> prime(n + 1, true);
prime[0] = prime[1] = 0;
for (int i = 2; i * i <= n; i++) {
if (prime[i])
for (int j = i * i; j <= n; j += i) {
prime[j] = 0;
}
}
vector<long long> p;
for (int i = 2; i <= prime.size(); i++)
if (prime[i]) p.push_back(i);
return p;
}
bool isprime(int n) {
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true && (n != 1);
}
int ncr(long long n, long long r) {
long long C[r + 1];
memset(C, 0, sizeof(C));
C[0] = 1;
for (long long i = 1; i <= n; i++) {
for (long long j = min(i, r); j > 0; j--)
C[j] = (C[j] + C[j - 1]) % 1000000007;
}
return C[r];
}
bool special(string s) {
for (int i = 0; i < s.size(); i++) {
if (s[i] == ' ') continue;
if (s[i] == '#')
return true;
else
return false;
}
return false;
}
void solve() {
cout << fixed << setprecision(10);
int n, d;
int a, v;
double t;
cin >> n >> a >> d;
double max_ans = 0;
for (int i = 0; i < n; i++) {
cin >> t >> v;
double s1 = 1.0 * v * v / (2 * a);
if (d < s1) {
t += sqrt(2.0 * d / a);
} else {
t += 1.0 * v / a + 1.0 * (d - s1) / v;
}
max_ans = max(t, max_ans);
cout << max_ans << '\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
while (t--) solve();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
double n, a, d;
cin >> n >> a >> d;
double Max = 0, time, t, v;
for (int i = 0; i < n; i++) {
cin >> t >> v;
if (d > v * v / (2 * a))
time = v / a + (d - v * v / (2 * a)) / v;
else
time = sqrt(2 * d / a);
time += t;
Max = max(Max, time);
cout << fixed << setprecision(5) << Max << endl;
}
return 0;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.