/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 27ms 532.0 KiB
#4 Accepted 63ms 1.281 MiB
#5 Accepted 62ms 924.0 KiB
#6 Accepted 62ms 920.0 KiB
#7 Accepted 59ms 856.0 KiB
#8 Accepted 53ms 924.0 KiB
#9 Accepted 55ms 924.0 KiB
#10 Accepted 52ms 764.0 KiB

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