#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mod 998244353
#define int long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<pair<pair<int,int>,int>,null_type,less<pair<pair<int,int>,int>>,rb_tree_tag,tree_order_statistics_node_update>;
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,m,d;
cin>>n>>m>>d;
d*=2;
vector<int>v(n);
for(auto &i:v){cin>>i;i*=2;}
while(m--){
int x;
cin>>x;
x*=2;
v.push_back(x);
sort(v.begin(),v.end());
int l=0,r=1000000000,mid,f;
r*=r;
while(l<=r){
mid=(l+r)/2;
vector<int>vv=v;
vv[0]-=mid;
bool bl=1;
for(int i=1;i<vv.size();i++){
vv[i]=max(vv[i]-mid,vv[i-1]+d);
if(abs(vv[i]-v[i])>mid)bl=0;
}
if(bl){
r=mid-1;
f=mid;
}else l=mid+1;
}
cout<<f/2;
if(f&1)cout<<".5";
cout<<' ';
}
}
/*
1
13
7 10 13 |4 |5 10| 8| 3 6 5 |7 10| 2
*/
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:30:26: 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]
30 | for(int i=1;i<vv.size();i++){
| ~^~~~~~~~~~
Main.cpp:40:13: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
40 | if(f&1)cout<<".5";
| ~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
356 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
472 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
4 ms |
528 KB |
Output is correct |
7 |
Correct |
3 ms |
524 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
356 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Correct |
3 ms |
348 KB |
Output is correct |
4 |
Correct |
5 ms |
472 KB |
Output is correct |
5 |
Correct |
3 ms |
348 KB |
Output is correct |
6 |
Correct |
4 ms |
528 KB |
Output is correct |
7 |
Correct |
3 ms |
524 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
335 ms |
7004 KB |
Output is correct |
10 |
Correct |
381 ms |
5468 KB |
Output is correct |
11 |
Correct |
276 ms |
5980 KB |
Output is correct |
12 |
Correct |
372 ms |
5468 KB |
Output is correct |
13 |
Correct |
265 ms |
5464 KB |
Output is correct |
14 |
Correct |
317 ms |
5476 KB |
Output is correct |
15 |
Correct |
309 ms |
5980 KB |
Output is correct |
16 |
Correct |
273 ms |
5464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1555 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1555 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |