Accepted
Code
#include<bits/stdc++.h>
using namespace std;
//ofstream file("output0.txt");
void solve()
{
int n,t1,t2; cin>>t1>>t2;
cin>>n;
int a[n+1],b[n+1];
int sum=0;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++) cin>>b[i];
sum = a[n];
int ans=1e9;
for(int i=1;i<=n;i++)
{
if(b[i]>min(t1,t2))
{
ans = min(ans,abs(sum-a[i]*2));
}
}
if (ans == 1e9) ans = -1;
cout<<ans<<endl;
//file<<ans<<endl;
}
int main(){
//freopen("input0.txt","r",stdin);
int t; cin>>t; while(t--) solve();}
Information
- Submit By
- Type
- Submission
- Problem
- P1030 A boring train journey
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-02-28 17:15:38
- Judged At
- 2024-11-11 03:43:09
- Judged By
- Score
- 100
- Total Time
- 63ms
- Peak Memory
- 1.281 MiB