답안 #472346

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472346 2021-09-13T12:04:20 Z AbdoMo Cipele (COCI18_cipele) C++17
18 / 90
1000 ms 1956 KB
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
const int mod = 1e9+7;
using namespace std;
bool comp(pair<int,int>&a ,pair<int,int>&b)
{
    if(a.first==b.first)
    {
        return a.second>b.second;
    }
    return a.first<b.first;

}
int gans(int n,int m,int arr[],int arr2[])
{
    int tans=0;
    bool vis1[100005]={};
    int c=0;
    for(int i=0;i<n;i++)
    {
        int t=1e13;
        int ind=0;
        for(int j=0;j<m;j++)
        {
            if(vis1[j])continue;
            if(abs(arr[i]-arr2[j])<=t)
            {
                t=abs(arr[i]-arr2[j]);
                ind = j;
            }

        }
        vis1[ind]=1;
        tans=max(tans,t);
        
    }
    return tans;
}
void solve()
{
    int n,m;
    cin>>n>>m;
    int arr[100005],arr2[100005];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<m;i++)
    {
        cin>>arr2[i];
    }
    int ans=1e13;
    sort(arr,arr+n);
    sort(arr2,arr2+m);
    ans=min(ans,gans(n,m,arr,arr2));
    ans=min(ans,gans(m,n,arr2,arr));

    reverse(arr,arr+n);
    ans=min(ans,gans(n,m,arr,arr2));
    ans=min(ans,gans(m,n,arr2,arr));

    reverse(arr2,arr2+m);
    ans=min(ans,gans(n,m,arr,arr2));
    ans=min(ans,gans(m,n,arr2,arr));

    reverse(arr2,arr2+m);
    ans=min(ans,gans(n,m,arr,arr2));
    ans=min(ans,gans(m,n,arr2,arr));
    cout<<ans<<endl;


}
int32_t main(){
	int t=1;
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //cin>>t;
	while(t--){solve();}
	return 0;
}

Compilation message

cipele.cpp: In function 'long long int gans(long long int, long long int, long long int*, long long int*)':
cipele.cpp:20:9: warning: unused variable 'c' [-Wunused-variable]
   20 |     int c=0;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 1868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1086 ms 1868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 1948 KB Output is correct
2 Correct 261 ms 1952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1868 KB Output is correct
2 Correct 250 ms 1956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 232 ms 1952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 254 ms 1952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 299 ms 1952 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 1876 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 1864 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 1872 KB Time limit exceeded
2 Halted 0 ms 0 KB -