#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,D,x,ans;
set<tuple<ll,ll,ll> >s;
void add(ll v)
{
ll l=v,r=v,sz=1,L,R,SZ;
auto it=s.lower_bound({l,r,1ll});
if(it!=s.begin()){
it--;
tie(L,R,SZ)=*it;
if(l<=R+D){
l=min(l,L);
r=max(r,R);
sz+=SZ;
s.erase(it);
}
}
it=s.lower_bound({l,r,1ll});
if(it!=s.end()){
}
tie(L,R,SZ)=*it;
if(L<=r+D){
l=min(l,L);
r=max(r,R);
sz+=SZ;
s.erase(it);
}
s.insert({l,r,sz});
ans=max(ans,(sz-1)*D+1-(r-l+1));
return;
}
int main()
{
scanf("%lld%lld%lld",&n,&m,&D);
for(ll i=1;i<=n;++i){
scanf("%lld",&x);
add(x);
}
for(ll i=1;i<=m;++i){
scanf("%lld",&x);
add(x);
printf("%.1lf ",(double)ans/2);
}
putchar(10);
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%lld%lld%lld",&n,&m,&D);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
38 | scanf("%lld",&x);
| ~~~~~^~~~~~~~~~~
Main.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | scanf("%lld",&x);
| ~~~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1563 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1563 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1544 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1544 ms |
348 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |