Submission #472297

# Submission time Handle Problem Language Result Execution time Memory
472297 2021-09-13T11:17:56 Z Ahmed57 Cipele (COCI18_cipele) C++14
18 / 90
71 ms 5344 KB
#include<bits/stdc++.h>
using namespace std;
void solve()
{


}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    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);
    }
    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;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 59 ms 5316 KB Output is correct
2 Incorrect 67 ms 5344 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 71 ms 5272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 716 KB Output is correct
2 Correct 3 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 844 KB Output is correct
2 Correct 3 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 5160 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 5044 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 4848 KB Output isn't correct
2 Halted 0 ms 0 KB -