Submission #472321

# Submission time Handle Problem Language Result Execution time Memory
472321 2021-09-13T11:42:09 Z Ahmed57 Cipele (COCI18_cipele) C++14
36 / 90
1000 ms 1868 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    vector<long long>arr(n),aee(m);
    for(int i =0;i<n;i++){
        cin>>arr[i];
    }
    for(int i = 0;i<m;i++){
        cin>>aee[i];
    }
    sort(arr.begin(),arr.end());sort(aee.begin(),aee.end());
    if(m>n){swap(arr,aee);swap(n,m);}
    if(n==m){
        long long sum = 0;
        for(int i = 0;i<n;i++){
            sum=max(sum,abs(arr[i]-aee[i]));
        }
        cout<<sum<<"\n";
    }else if(n>m){
        long long ans = 0;
        int y = 0;
        for(int i = 0;i<m;i++){
        long long f = 1e18, g=0;
        for(int j = 0;j<n;j++){
            if(f>abs(arr[j]-aee[i])){
                f = abs(arr[j]-aee[i]);
                g = j;
            }
        }
        ans = max(ans,f);
        arr.erase(arr.begin()+g);
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:26:13: warning: unused variable 'y' [-Wunused-variable]
   26 |         int y = 0;
      |             ^
# Verdict Execution time Memory Grader output
1 Correct 81 ms 1740 KB Output is correct
2 Correct 97 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 1740 KB Output is correct
2 Correct 98 ms 1868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 324 KB Output is correct
2 Correct 49 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 51 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 716 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 45 ms 728 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1484 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 1612 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 1484 KB Time limit exceeded
2 Halted 0 ms 0 KB -