#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=1e12;
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((double)lft[i-1]+half, (double)rgt[i]+half));
mn=min(mn, (double)(lft[i-1]+rgt[i]+half+half)/(double)2);
}
cout << max((double)0,mn) << " ";
}
return 0;
}
Compilation message
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++){
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1545 ms |
1112 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1545 ms |
1112 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |