/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 764.0 KiB
#2 Accepted 1ms 352.0 KiB
#3 Wrong Answer 9ms 576.0 KiB
#4 Accepted 18ms 1.305 MiB
#5 Accepted 17ms 908.0 KiB
#6 Accepted 17ms 832.0 KiB
#7 Accepted 17ms 944.0 KiB
#8 Accepted 16ms 956.0 KiB
#9 Accepted 17ms 948.0 KiB
#10 Wrong Answer 15ms 764.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
const long long M=2e5+10,MOD=1000000007;
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){
                mx=min(mx,cur_pos-a[i]);
            }
          }

      }
      for(int i=n-1;i>=0;i--){
        int cur_pos=c-a[i];
       // if(cur_pos==a[i])continue;
        if(cur_pos<=a[i]){
            if(b[i]>t2)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:28:15
Judged At
2024-10-03 14:00:42
Judged By
Score
80
Total Time
18ms
Peak Memory
1.305 MiB