QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#697727 | #6429. Let's Play Curling | 552Hz# | WA | 1ms | 5632kb | C++14 | 1.8kb | 2024-11-01 15:30:33 | 2024-11-01 15:30:33 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=200010;
const ll mod=998244353;
int n,m;
ll a[N],b[N];
void solve(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];a[i]*=2;
}
std::vector<ll> q;
for(int i=1;i<=m;i++){
cin>>b[i];b[i]*=2;
q.push_back(b[i]);
}
ll ans=0;
sort(q.begin(),q.end());
q.push_back(1e17);
sort(a+1,a+1+n);
sort(b+1,b+1+m);
for(int i=1;i<=n;i++){
ll pos=a[i];
ll w=lower_bound(q.begin(),q.end(),pos)-q.begin();
ll dis=1e18;
dis=min(dis,q[w]-pos);
if(w!=0){
w--;
}
dis=min(dis,pos-q[w]);
cout<<dis<<" ";
int r=0,l=0;
if(dis==0){
continue;
}
for(int j=20;j>=0;j--){
if((r+(1<<j))+i>n){
continue;
}
if(a[(r+(1<<j))+i]-a[i]<dis){
r+=(1<<j);
}
}
for(int j=20;j>=0;j--){
if(i-(l+(1<<j))<1){
continue;
}
if(a[i]-a[i-(l+(1<<j))]<dis){
l+=(1<<j);
}
}
r=r+i;
l=i-l;
ans=max(ans,1ll*(r-l+1));
}
for(int i=1;i<n;i++){
ll pos=(a[i]+a[i+1])/2;
ll w=lower_bound(q.begin(),q.end(),pos)-q.begin();
ll dis=1e18;
dis=min(dis,q[w]-pos);
if(w!=0){
w--;
}
dis=min(dis,pos-q[w]);
cout<<dis<<" ";
int r=0,l=0;
if(dis==0){
continue;
}
for(int j=20;j>=0;j--){
if((r+(1<<j))+i>n){
continue;
}
if(a[(r+(1<<j))+i]-a[i]<dis){
r+=(1<<j);
}
}
for(int j=20;j>=0;j--){
if(i-(l+(1<<j))<1){
continue;
}
if(a[i]-a[i-(l+(1<<j))]<dis){
l+=(1<<j);
}
}
r=r+i;
l=i-l;
ans=max(ans,1ll*(r-l+1));
}
if(ans==0){
cout<<"Impossible"<<endl;
}else{
cout<<ans<<endl;
}
//cout<<ans<<endl;
}
int main(){
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int _=1;
cin>>_;
while(_--){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5632kb
input:
3 2 2 2 3 1 4 6 5 2 5 3 7 1 7 3 4 3 1 10 1 1 7 7
output:
2 2 3 2 0 2 0 2 6 6 1 1 0 4 6 3 0 Impossible
result:
wrong answer 1st lines differ - expected: '2', found: '2 2 3 2'