/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 336.0 KiB
#2 Accepted 2ms 532.0 KiB
#3 Accepted 46ms 332.0 KiB
#4 Accepted 105ms 1.281 MiB
#5 Accepted 103ms 920.0 KiB
#6 Accepted 91ms 928.0 KiB
#7 Accepted 90ms 924.0 KiB
#8 Accepted 87ms 920.0 KiB
#9 Accepted 92ms 916.0 KiB
#10 Accepted 90ms 540.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-11-11 03:43:09
Judged By
Score
100
Total Time
105ms
Peak Memory
1.281 MiB