Submission #25847400


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,m;
  cin>>n>>m;

  vector<pair<int,int>> v;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    v.emplace_back(a,1);
  }
  for(int i=0;i<m;i++){
    int b;
    cin>>b;
    v.emplace_back(b,2);
  }

  sort(v.begin(),v.end());

  int ans=2e9;
  for(int i=0;i<n+m-1;i++){
    if(v[i].second!=v[i+1].second){
      ans=min(ans,v[i+1].first-v[i].first);
    }
  }

  cout<<ans<<endl;
}

Submission Info

Submission Time
Task C - Min Difference
User Mitsubachi
Language C++ (GCC 9.2.1)
Score 300
Code Size 475 Byte
Status AC
Exec Time 146 ms
Memory 7452 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 20
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, small_00.txt, small_01.txt, small_02.txt, small_03.txt, small_04.txt
Case Name Status Exec Time Memory
example_00.txt AC 7 ms 3628 KiB
example_01.txt AC 2 ms 3492 KiB
example_02.txt AC 2 ms 3432 KiB
hand_00.txt AC 88 ms 7216 KiB
hand_01.txt AC 128 ms 7208 KiB
random_00.txt AC 140 ms 7204 KiB
random_01.txt AC 140 ms 7292 KiB
random_02.txt AC 136 ms 7452 KiB
random_03.txt AC 142 ms 7368 KiB
random_04.txt AC 143 ms 7364 KiB
random_05.txt AC 143 ms 7232 KiB
random_06.txt AC 146 ms 7336 KiB
random_07.txt AC 146 ms 7232 KiB
random_08.txt AC 143 ms 7392 KiB
random_09.txt AC 145 ms 7288 KiB
small_00.txt AC 10 ms 3556 KiB
small_01.txt AC 11 ms 3716 KiB
small_02.txt AC 6 ms 3716 KiB
small_03.txt AC 11 ms 3528 KiB
small_04.txt AC 4 ms 3432 KiB