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;
const int mod=1e9+7;
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n,m,D; cin >> n >> m >> D;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
for (int _i = 0; _i < m; _i++)
{
int x; cin >> x;
a.push_back(x);
sort(a.begin(),a.end());
vector<int> lft(a.size(),0);
vector<int> rgt(a.size(),0);
for (int i = 1; i < a.size(); i++)
{
lft[i]=lft[i-1]+(D-(a[i]-a[i-1]));
}
for (int i = a.size()-2; i >= 0; i--)
{
rgt[i]=rgt[i+1]+(D-(a[i+1]-a[i]));
}
double mn=1e9;
for (int i = 0; i < a.size(); i++){
mn=min(mn, (double)max(lft[i], rgt[i]));
if(i==0) continue;
double half=(double)(D-(a[i]-a[i-1]))/(double)2;
mn=min(mn, max(lft[i-1]+half, rgt[i]+half));
}
cout << max((double)0,mn) << " ";
}
return 0;
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:18:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for (int i = 1; i < a.size(); i++)
| ~~^~~~~~~~~~
Main.cpp:27:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for (int i = 0; i < a.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... |