Submission #472271

# Submission time Handle Problem Language Result Execution time Memory
472271 2021-09-13T10:50:47 Z HossamHero7 Cipele (COCI18_cipele) C++14
27 / 90
1000 ms 1092 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
    int n,m;
    cin>>n>>m;
    vector <int> v1(n);
    vector <int> v2(m);
    for(auto &i:v1) cin>>i;
    for(auto &i:v2) cin>>i;
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    if(v1.size() < v2.size()) swap(v1,v2),swap(n,m);
    ll idx = 0;
    ll ans = 1e18;
    for(int i=0;i<n-(m-1);i++){
        int mx = 0;
        int cnt=0;
        for(int j=i;j<i+m;j++){
            mx = max(mx,abs(v1[j]-v2[cnt++]));
        }
        ans = min(ans,(ll)mx);
    }
    cout<<ans<<endl;
}
int main()
{
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Compilation message

cipele.cpp: In function 'void solve()':
cipele.cpp:16:8: warning: unused variable 'idx' [-Wunused-variable]
   16 |     ll idx = 0;
      |        ^~~
# Verdict Execution time Memory Grader output
1 Correct 76 ms 1064 KB Output is correct
2 Correct 109 ms 1064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 1064 KB Output is correct
2 Correct 106 ms 1092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 6 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1080 ms 844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 988 ms 980 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 844 KB Time limit exceeded
2 Halted 0 ms 0 KB -