/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 412.0 KiB
#2 Accepted 1ms 412.0 KiB
#3 Accepted 6ms 412.0 KiB
#4 Accepted 11ms 1.195 MiB
#5 Accepted 11ms 828.0 KiB
#6 Accepted 11ms 796.0 KiB
#7 Accepted 11ms 796.0 KiB
#8 Accepted 11ms 824.0 KiB
#9 Accepted 11ms 796.0 KiB
#10 Accepted 10ms 412.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+10,MOD=2000000007;
typedef long long ll;
int fre[26][M];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    cin>>t;
    while(t--){
    
       int n;
      // cin>>n;
       int t1,t2;
       cin>>t1>>t2>>n;
       vector<int>a(n),b(n);
       int mx=MOD;
       for(auto &i:a)cin>>i;
        for(auto &i:b)cin>>i;
        int c=a[n-1];
      for(int i=0;i<n;i++){
          int cur_pos=c-a[i];
          if(cur_pos==a[i])continue;
          if(a[i]<cur_pos){
            if(b[i]>t1 || b[i]>t2){
                mx=min(mx,cur_pos-a[i]);
            }
          }
          if(a[i]>cur_pos){
            if(b[i]>t2 || b[i]>t1)mx=min(mx,a[i]-cur_pos);
          }

      }
      
      if(mx==MOD)mx=-1;
      cout<<mx<<"\n";
    

    
   }
   return 0;
 
}

Information

Submit By
Type
Submission
Problem
P1030 A boring train journey
Contest
Brain booster #2
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-06 15:53:48
Judged At
2024-03-06 15:53:48
Judged By
Score
100
Total Time
11ms
Peak Memory
1.195 MiB