Problem:
Problem A:
Traffic Analysis
There are two cameras which observe the up line and the down line respectively on the double lane (please see the following figure). These cameras are located on a line perpendicular to the lane, and we call the line 'monitoring line.' (the red line in the figure)
Monitoring systems are connected to the cameras respectively.
When a car passes through the monitoring line, the corresponding monitoring system records elapsed time (sec) from the start of monitoring.
Your task is to write a program which reads records of the two monitoring systems and prints the maximum time interval where cars did not pass through the monitoring line.
The two monitoring system start monitoring simultaneously. The end of monitoring is indicated by the latest time in the records.
Input
The input consists of multiple datasets. Each dataset consists of:
n m
tl
1
tl
2
...
tl
n
tr
1
tr
2
...
tr
m
n
,
m
are integers which represent the number of cars passed through monitoring line on the up line and the down line respectively.
tl
i
,
tr
i
are integers which denote the elapsed time when
i
-th car passed through the monitoring line for the up line and the down line respectively. You can assume that
tl
1
<
tl
2
< ... <
tl
n
、
tr
1
<
tr
2
< ... <
tr
m
.
You can also assume that
n
,
m
≤ 10000, and 1 ≤
tl
i
,
tr
i
≤ 1,000,000.
The end of input is indicated by a line including two zero.
Output
For each dataset, print the maximum value in a line.
Sample Input
4 5
20 35 60 70
15 30 40 80 90
3 2
10 20 30
42 60
0 1
100
1 1
10
50
0 0
Output for the Sample Input
20
18
100
40

Submitted solutions:

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, m;

    while (cin >> n >> m, n || m)
    {
        vector<int> time;
        int tmp, ans = 0;
        for (int i = 0; i < n + m; i++)
        {
            cin >> tmp;
            time.push_back(tmp);
        }
        sort(time.begin(), time.end());
        ans = time[0];
        for (int i = 1; i < time.size(); i++)
        {
            ans = max(ans, time[i] - time[i - 1]);
        }
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3448
final_rank: 16

code_snippet: #include <bits/stdc++.h>

using namespace std;

int main()
{
    while (true)
    {
        int n, m;
        cin >> n >> m;
        if (n == 0 && m == 0)
        {
            break;
        }

        set<int> st;
        for (int i = 0; i < n; i++)
        {
            int t;
            cin >> t;
            st.insert(t);
        }
        for (int i = 0; i < m; i++)
        {
            int t;
            cin >> t;
            st.insert(t);
        }
        int ans = 0;
        int pt = 0;
        for (auto u : st)
        {
            if (ans < u - pt)
            {
                ans = u - pt;
            }
            pt = u;
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3912
final_rank: 18

code_snippet: #include <cstdio>
#include <vector>
#include <queue>
#include <functional>
#include <iostream>

int L[10002];
int R[10002];
int B[20010];

int main()
{
	int n, m;
	while (1)
	{
		std::cin >> n >> m;
		if (n == 0 && m == 0)
			break;

		for (int i = 0; i < n; i++)
			std::cin >> L[i];
		for (int i = 0; i < m; i++)
			std::cin >> R[i];

		int i = 0;
		int j = 0;
		L[n] = R[m] = 1000001;
		int len = 0;
		for (int k = 0; k < m + n; k++)
		{
			if (L[i] <= R[j])
			{
				B[k] = L[i++];
			}
			else
			{
				B[k] = R[j++];
			}

			if (k > 0)
			{
				if (B[k] - B[k - 1] > len)
					len = B[k] - B[k - 1];
			}
			else
			{
				len = B[0];
			}
		}

		std::cout << len << std::endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3192
final_rank: 8

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int solve(int n,int m){
    vector<int>v1;
    for(int i = 0;i < n;i++){
        int g;
        cin >> g;
        v1.push_back(g);
    }
    vector<int>v2;
    for(int i = 0;i < m;i++){
        int g;
        cin >> g;
        v2.push_back(g);
    }
    copy(v2.begin(),v2.end(),back_inserter(v1));
    sort(v1.begin(),v1.end());
    int max = v1[0];
    for(int i = 1;i < n+m;i++){
        if(max < v1[i] - v1[i - 1]){
            max = v1[i] - v1[i - 1];
        }
    }
    return max;
}
int main(){
    vector<int>a;
    while(1){
        int n ,m;
        cin >> n >> m;
        if(n == m && n == 0)break;
        
        a.push_back(solve(n,m));
    }
    for(int i = 0;i < a.size();i++){
        cout << a[i] << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3188
final_rank: 6

code_snippet: #include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef vector<int> VI;

int main(void) {
  int n,m;
  for(;cin>>n>>m&&n+m;){
    VI a(n+m+1);
    REP(i,0,n+m)cin>>a[i];
    sort(a.begin(),a.end());
    int k=0;
    REP(i,0,a.size()-1)k=max(k,a[i+1]-a[i]);
    cout<<k<<"\n";
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3192
final_rank: 8

code_snippet: #include<iostream>
using namespace std;

int main()
{
    int n, m;

    while( cin >> n >> m )
    {
        if( n + m == 0 )
            break;
        
        int* a = new int[n];
        int* b = new int[m];
        int* c = new int[n+m];

        for( int i = 0; i < n; i++ )
            cin >> a[i];

        for( int i = 0; i < m; i++ )
            cin >> b[i];

        int i = 0, j = 0;
        while( i < n && j < m )
        {
            if( a[i] < b[j] )
            {
                c[i+j] = a[i];
                i++;
            }
            else
            {
                c[i+j] = b[j];
                j++;
            }
        }
        while( i < n )
        {
            c[i+j] = a[i];
            i++;
        }
        while( j < m )
        {
            c[i+j] = b[j];
            j++;
        }

        int ma = c[0];
        for( i = 0; i < n + m - 1; i++ )
            ma = ma > c[i+1] - c[i] ? ma : c[i+1] - c[i];

        cout << ma << endl;

        delete a, b, c;
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3364
final_rank: 15

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n, m;
    while(cin >> n >> m, n+m){
        vector<int> v(n+m);
        for(int i = 0; i < n+m; i++)    cin >> v[i];
        sort(v.begin(), v.end());
        int ans = v[0];
        for(int i = 1; i < n+m; i++)    ans = max(ans, v[i]-v[i-1]);
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3164
final_rank: 3

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

int main(){
    int n,m;
    while(true){
        cin>>n>>m;
        if(n==0&&m==0)break;
        vector<int> v;
        for (int i = 0; i < n; ++i) {
            int t;
            cin>>t;
            v.emplace_back(t);
        }
        for (int i = 0; i < m; ++i) {
            int t;
            cin>>t;
            v.emplace_back(t);
        }
        v.emplace_back(0);
        sort(v.begin(),v.end());
        int ans=0;
        for (size_t i = 1; i < v.size(); ++i) {
            ans=max(ans,v[i]-v[i-1]);
        }
        cout<<ans<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3236
final_rank: 13

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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int main(){
    while(1){
        int n, m; cin>>n>>m;
        if(n==0 && m==0) return 0;
        vector<ll> a(n+m);
        for(int i=0; i<n+m; i++) cin>>a[i];
        sort(a.begin(), a.end());
        ll gap=a[0];
        for(int i=0; i<n+m-1; i++){
            gap=max(gap, a[i+1]-a[i]);
        }
        cout << gap << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3168
final_rank: 5

code_snippet: #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main(){
  int n, m;
  while(cin >> n >> m, n or m){
    vector<int> V(n+m+1);
    V[0] = 0;
    for(int i = 0; i < n+m; ++i) cin >> V[i+1];
    sort(V.begin(), V.end());
    int ans = 0;
    for(int i = 0; i < n+m; ++i) ans = max(ans, V[i+1]-V[i]);
    cout << ans << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3240
final_rank: 14

code_snippet: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n+m==0)break;
    vi a(n+m+1);
    a[0]=0;
    rep(i,n)cin>>a[i+1];
    rep(i,m)cin>>a[n+i+1];
    sort(all(a));
    int ans=0;
    rep(i,n+m)ans=max(ans,a[i+1]-a[i]);
    cout<<ans<<endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3216
final_rank: 10

code_snippet: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n, m;
	while (cin >> n >> m){
		if (!n && !m)return 0;
		long long a[20001], ans = 0;
		for (int i = 0; i < n + m; i++)cin >> a[i]; sort(a, a + n + m);
		ans = a[0];
		for (int i = 1; i < n + m; i++)ans = max(ans, a[i] - a[i - 1]);
		cout << ans << endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3120
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a+b){
    vector<int>v;
    for(int i=0;i<a+b;i++){
      int p;
      cin>>p;
      v.push_back(p);
    }
    sort(v.begin(),v.end());
    int ans=0,p=0;
    for(int i=0;i<a+b;i++){
      ans=max(ans,v[i]-p);
      p=v[i];
    }
    cout<<ans<<endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3216
final_rank: 10

code_snippet: #include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>

using namespace std;

int n, m, t[300000];

int main(){
	
	vector<int> ans;
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		for (int i = 0; i < n; i++)cin >> t[i];
		for (int i = n; i < m+n; i++)cin >> t[i];
		sort(t, t + n + m);
		int Max = t[0];
		for (int i = 0; i < n + m - 1; i++)Max = max(Max, t[i + 1] - t[i]);
		ans.push_back(Max);
	}
	for (int i = 0; i < ans.size(); i++)cout << ans[i] << endl;
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3164
final_rank: 3

code_snippet: #include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n+m){
    int t[20005];
    for(int i=0;i<n+m;++i)
      cin>>t[i];
    sort(t,t+n+m);
    int ans=t[0];
    for(int i=1;i<n+m;++i){
      ans=max(ans,t[i]-t[i-1]);
    }
    cout<<ans<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3220
final_rank: 12

code_snippet: #include <iostream>
#include <set>
#define MAX(a,b) ((a>b)?(a):(b))
using namespace std;

int main(void){
	int n,m;
	int a;
	while(cin>>n>>m,n||m){
		std::set<int> ms;
		for(int i=0;i<n+m;i++)cin>>a,ms.insert(a);
		int m=*(ms.begin());
		for(__typeof(ms.begin()) it=++ms.begin(),b=ms.begin();it!=ms.end();it++,b++){
			m=MAX(m,*it-*b);
		}
		cout<<m<<endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3824
final_rank: 17

code_snippet: #include <iostream>
#include <set>
#define MAX(a,b) ((a>b)?(a):(b))
using namespace std;

int main(void){
	int n,m;
	int a;
	while(cin>>n>>m,n||m){
		std::multiset<int> ms;
		for(int i=0;i<n+m;i++)cin>>a,ms.insert(a);
		int m=*(ms.begin());
		for(__typeof(ms.begin()) it=++ms.begin(),b=ms.begin();it!=ms.end();it++,b++){
			m=MAX(m,*it-*b);
		}
		cout<<m<<endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3928
final_rank: 19

code_snippet: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n, m;
	while (cin >> n >> m, n || m) {
		vector<int>v(1,0);
		rep(i, 0, n + m) {
			int a; cin >> a;
			v.push_back(a);
		}
		sort(all(v));
		vector<int>ans;
		rep(i, 0, v.size()-1) {
			ans.push_back(v[i + 1] - v[i]);
		}
		cout << *max_element(all(ans)) << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3156
final_rank: 2

code_snippet: #include<iostream>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
int main() {
	int n, m, x;
	while (cin >> n >> m&&(n != 0||m!=0)) {
		multiset<int>a;
		a.insert(0);
		for (int i = 0; i < n; i++) {
			cin >> x;
			a.insert(x);
		}
		for (int j = 0; j < m; j++) {
			cin >> x;
			a.insert(x);
		}
		multiset<int>::iterator it = a.begin();
		it++;
		int sa = 0;
		for (int i = 1; i <= n + m; i++) {
			sa = max(sa, (*it) - (*--it));
			it++;
			it++;
		}
		cout << sa << endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 4044
final_rank: 20

code_snippet: #include "bits/stdc++.h"
using namespace std;

int main() {
	while (1) {

		int N, M; cin >> N >> M;
		if (!N&&!M)break;
		vector<int>vs(N + M);
		for (int i = 0; i < N + M; ++i) {
			cin >> vs[i];
		}
		vs.emplace_back(0);
		sort(vs.begin(), vs.end());
		int ans = 0;
		for (int i = 0; i < vs.size() - 1; ++i) {
			ans = max(ans, vs[i + 1] - vs[i]);
		}
		cout << ans << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3188
final_rank: 6