/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 10ms 576.0 KiB
#4 Accepted 19ms 1.312 MiB
#5 Accepted 19ms 820.0 KiB
#6 Accepted 19ms 828.0 KiB
#7 Accepted 19ms 816.0 KiB
#8 Accepted 17ms 820.0 KiB
#9 Accepted 18ms 832.0 KiB
#10 Accepted 18ms 576.0 KiB

Code

#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")
using namespace std;

void solve(int cs) {
  int la, lb;
  cin >> la >> lb;
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> l(n);
  for (int &i : a) cin >> i;
  for (int &i : l) cin >> i;

  int res = 1e9;
  for (int i = 0; i < n; i++) {
    if (l[i] > lb) {
      res = min(res, abs(a.back() - a[i] - a[i]));
    }
  }
  for (int i = 0; i < n; i++) {
    if (l[i] > la) {
      res = min(res, abs(a.back() - a[i] - a[i]));
    }
  }
  cout << (res == 1e9 ? -1 : res) << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  cin >> tc;
  for (int cs = 1; cs <= tc; cs++) {
    solve(cs);
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1030 A boring train journey
Language
C++17 (G++ 13.2.0)
Submit At
2024-07-14 08:26:56
Judged At
2024-11-11 03:26:22
Judged By
Score
100
Total Time
19ms
Peak Memory
1.312 MiB