# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
81642 |
2018-10-25T18:11:34 Z |
IvanC |
Cipele (COCI18_cipele) |
C++17 |
|
75 ms |
11372 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++){
if(ptr >= M) return 0;
while(ptr < M && abs(A[i] - B[ptr]) > X ){
ptr++;
}
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
cipele.cpp: In function 'int main()':
cipele.cpp:59:10: warning: 'resp' may be used uninitialized in this function [-Wmaybe-uninitialized]
cout << resp << endl;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
3060 KB |
Output is correct |
2 |
Correct |
53 ms |
4728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
6600 KB |
Output is correct |
2 |
Correct |
75 ms |
8316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8316 KB |
Output is correct |
2 |
Correct |
4 ms |
8316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8316 KB |
Output is correct |
2 |
Incorrect |
5 ms |
8316 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8316 KB |
Output is correct |
2 |
Correct |
4 ms |
8316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8316 KB |
Output is correct |
2 |
Incorrect |
4 ms |
8316 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
8316 KB |
Output is correct |
2 |
Correct |
5 ms |
8316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
8316 KB |
Output is correct |
2 |
Correct |
34 ms |
8316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
50 ms |
8376 KB |
Output is correct |
2 |
Correct |
26 ms |
8376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
9708 KB |
Output is correct |
2 |
Correct |
46 ms |
11372 KB |
Output is correct |