Submission #84510

# Submission time Handle Problem Language Result Execution time Memory
84510 2018-11-15T19:49:09 Z memetkagan44 Cipele (COCI18_cipele) C++11
27 / 90
1000 ms 10024 KB
#include<bits/stdc++.h>
using namespace std;
int n,m,a,res=INT_MAX;
vector<int> v1,v2;
int main(){
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        v1.push_back(a);
    }
    for(int i=0;i<m;i++){
        scanf("%d",&a);
        v2.push_back(a);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    if(n>=m){
        for(int i=0;i<=n-m;i++){
            int maxi=INT_MIN;
            for(int j=0,k=i;j<m;j++,k++)
                maxi=max(maxi,abs(v2[j]-v1[k]));
            res=min(res,maxi);
        }
    }
    else{
        for(int i=0;i<=m-n;i++){
            int maxi=INT_MIN;
            for(int j=0,k=i;j<n;j++,k++)
                maxi=max(maxi,abs(v1[j]-v2[k]));
            res=min(res,maxi);
        }
    }
    printf("%d\n",res);
    return 0;
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&n,&m);
     ~~~~~^~~~~~~~~~~~~~~
cipele.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a);
         ~~~~~^~~~~~~~~
cipele.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a);
         ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 35 ms 3056 KB Output is correct
2 Correct 57 ms 4924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6716 KB Output is correct
2 Correct 56 ms 8304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8304 KB Output is correct
2 Correct 5 ms 8304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 8304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 8304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 8304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 8304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 8304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 8644 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 10024 KB Time limit exceeded
2 Halted 0 ms 0 KB -