/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 488.0 KiB
#2 Accepted 2ms 332.0 KiB
#3 Accepted 36ms 544.0 KiB
#4 Accepted 69ms 1.281 MiB
#5 Accepted 75ms 1.066 MiB
#6 Accepted 88ms 924.0 KiB
#7 Accepted 78ms 916.0 KiB
#8 Accepted 63ms 1.02 MiB
#9 Accepted 51ms 1.027 MiB
#10 Accepted 47ms 852.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 16:48:24
Judged At
2024-10-03 14:02:31
Judged By
Score
100
Total Time
88ms
Peak Memory
1.281 MiB