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>
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
ll n, m, d;
cin >> n >> m >> d;
vector<ll> a(n);
for(ll &x : a) cin >> x;
sort(a.begin(), a.end());
if(!n) {
vector<ll> vec; vec.push_back(-1e18);
ll ans = 0;
int vec_size = 1;
while(m--) {
ll x; cin >> x;
vec_size++;
vec.push_back(x);
if(vec[vec_size-1] - vec[vec_size-2] < d) ans = max(ans, d - vec[vec_size-1] + vec[vec_size-2]);
vec[vec_size-1] = max(vec[vec_size-1], vec[vec_size-2] + d);
if(ans % 2 == 0) {
cout << ans / 2 << " ";
} else {
cout << ans / 2 << ".5 ";
}
}
return 0;
}
while(m--) {
ll x;
cin >> x;
a.push_back(x);
sort(a.begin(), a.end());
ll ans = 0;
vector<ll> vec; vec.push_back(-1e18);
for(ll &x : a) vec.push_back(x);
for(int i=1; i<vec.size(); i++) {
if(vec[i] - vec[i-1] < d) ans = max(ans, d - vec[i] + vec[i-1]);
vec[i] = max(vec[i-1] + d, vec[i]);
}
if(ans % 2 == 0) {
cout << ans / 2 << " ";
} else {
cout << ans / 2 << ".5 ";
}
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i=1; i<vec.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... |