This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O1")
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
#define F first
#define S second
const ld PI = 3.1415926535;
const int N = 5e5 + 2;
const int M = 1e7 + 1;
int mod = 998244353;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;
int mult(int a, int b) {
return a * 1LL * b % mod;
}
int sum(int a, int b) {
if (a + b < 0)
return a + b + mod;
if (a + b >= mod)
return a + b - mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0)
return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % mod;
} else {
ll b = binpow(a, n / 2);
return b * b % mod;
}
}
int n, m;
ld d;
vector<ld> x;
ld getans(){
ld cur = x[0], ca = 0;
for(int i = 1; i < x.size(); i++){
if(x[i] + ca - cur >= d){
ld nx;
if(x[i] - cur >= d){
nx = max(x[i] - ca, cur + d);
}else{
nx = cur + d;
}
cur = nx;
continue;
}
ld ad = (d - x[i] - ca + cur) / 2;
cur = cur - ad + d;
ca += ad;
}
return ca;
}
void solve() {
cin >> n >> m >> d;
for(int i = 1; i <= n; i++){
int ps;
cin >> ps;
x.push_back((ld)ps);
}
for(int i = 1; i <= m; i++){
int ps;
cin >> ps;
x.push_back((ld)ps);
sort(x.begin(), x.end());
ll ans = getans() * 2;
if(ans % 2 == 0){
cout << ans / 2 << ' ';
}else{
cout << fixed << setprecision(1) << (ld)ans / 2 << ' ';
}
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'ld getans()':
Main.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int i = 1; i < x.size(); i++){
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |