/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 484.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Wrong Answer 9ms 580.0 KiB
#4 Accepted 19ms 1.316 MiB
#5 Accepted 18ms 980.0 KiB
#6 Accepted 18ms 948.0 KiB
#7 Accepted 18ms 952.0 KiB
#8 Accepted 17ms 840.0 KiB
#9 Accepted 18ms 820.0 KiB
#10 Wrong Answer 17ms 640.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-11-11 03:41:38
Judged By
Score
80
Total Time
19ms
Peak Memory
1.316 MiB