# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81643 | 2018-10-25T18:13:27 Z | IvanC | Cipele (COCI18_cipele) | C++17 | 114 ms | 1800 KB |
#include <bits/stdc++.h> using namespace std; vector<int> A,B; int N,M; int guloso_match(int X){ int ptr = 0; for(int i = 0;i<N;i++){ while(ptr < M && abs(A[i] - B[ptr]) > X ){ ptr++; } if(ptr >= M){ return 0; } else{ ptr++; } } return 1; } int main(){ cin.tie(0);ios_base::sync_with_stdio(0); cin >> N >> M; for(int i = 0;i<N;i++){ int x; cin >> x; A.push_back(x); } for(int i = 0;i<M;i++){ int x; cin >> x; B.push_back(x); } if(N > M){ swap(A,B); swap(N,M); } sort(A.begin(),A.end()); sort(B.begin(),B.end()); int ini = 0, fim = 1e9, meio,resp; while(ini <= fim){ meio = ini + (fim - ini)/2; if(guloso_match(meio)){ resp = meio; fim = meio - 1; } else{ ini = meio + 1; } } cout << resp << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 114 ms | 1524 KB | Output is correct |
2 | Correct | 51 ms | 1604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 52 ms | 1780 KB | Output is correct |
2 | Correct | 52 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1800 KB | Output is correct |
2 | Correct | 4 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1800 KB | Output is correct |
2 | Correct | 4 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1800 KB | Output is correct |
2 | Correct | 4 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1800 KB | Output is correct |
2 | Correct | 4 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1800 KB | Output is correct |
2 | Correct | 4 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 1800 KB | Output is correct |
2 | Correct | 34 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 1800 KB | Output is correct |
2 | Correct | 25 ms | 1800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 50 ms | 1800 KB | Output is correct |
2 | Correct | 43 ms | 1800 KB | Output is correct |