Submission #472204

# Submission time Handle Problem Language Result Execution time Memory
472204 2021-09-13T09:17:28 Z AbdoMo Cipele (COCI18_cipele) C++17
18 / 90
70 ms 5764 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;

}
void solve()
{
    int n,m;
    cin>>n>>m;
    int arr[100000];
    multiset<int>ms;
    if(n<=m)
    {
        for(int i=0;i<n;i++)
        {
            cin>>arr[i];
        }
        for(int i=0;i<m;i++)
        {
            int x;
            cin>>x;
            ms.insert(x);
        }
        sort(arr,arr+n);
    }
    else
    {
        for(int i=0;i<n;i++)
        {
            int x;
            cin>>x;
            ms.insert(x);

        }
        for(int i=0;i<m;i++)
        {
            cin>>arr[i];
        }
        sort(arr,arr+m);
    }
    /*cout<<min(n,m)<<endl;
    for(int i=0;i<min(n,m);i++)
    {
        cout<<arr[i]<<" x ";
    }
    cout<<endl;
    for(auto i=ms.begin();i!=ms.end();i++)
    {
        cout<<*i<<" ";
    }
    cout<<endl;*/
    int ans=0;
    for(int i=0;i<min(n,m);i++)
    {
        int x = arr[i];
        auto it1=ms.upper_bound(x);
        auto it2=ms.upper_bound(x);
        if(it1!=ms.begin())
        {
            it1--;

        }
        if(it2!=ms.end())
        {
            if(abs(x-*it1)<=abs(x-*it2))
            {
                ans=max(ans,abs(x-*it1));
                ms.erase(it1);
            }
            else
            {
                ans=max(ans,abs(x-*it2));
                ms.erase(it2);
            }
        }
        else
        {
            ans=max(ans,abs(x-*it1));
            ms.erase(it1);
        }


    }
    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;
}
# Verdict Execution time Memory Grader output
1 Correct 56 ms 5700 KB Output is correct
2 Incorrect 66 ms 5764 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 5692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1100 KB Output is correct
2 Correct 3 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1228 KB Output is correct
2 Correct 3 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 5580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 5560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 5348 KB Output isn't correct
2 Halted 0 ms 0 KB -