# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472435 |
2021-09-13T14:33:43 Z |
_L__ |
Cipele (COCI18_cipele) |
C++17 |
|
400 ms |
3668 KB |
// This code is written by _L__
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type , less<T> , rb_tree_tag , tree_order_statistics_node_update>;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7, N = 1e5+300, inf = 1e18;
const ld E = 1e-6;
#define ff first
#define ss second
ll a[N], b[N], n, m;
bool check(ll mid){
ll cnt = 0;
ll cur = 0-1;
if(n<=m){
for(int i = 0; i < n; ++i){
ll l = lower_bound(b, b+m, a[i]-mid)-b;
ll r = upper_bound(b, b+m, a[i]+mid)-b-1;
if(l>r)return 0;
if(cur+1 > r)return 0;
cur = max(l, cur+1);
}
return 1;
} else {
for(int i = 0; i < m; ++i){
ll l = lower_bound(a, a+n, b[i]-mid)-a;
ll r = upper_bound(a, a+n, b[i]+mid)-a-1;
if(l>r) return 0;
if(cur+1 > r) return 0;
cur = max(l, cur+1);
}
return 1;
}
}
ll lower(){
ll l = 0, r = 1e11, ans = 0;
while(l <= r){
ll mid = (l+r)/2;
if(check(mid)){
ans = mid;
r = mid-1;
} else l = mid+1;
}
return ans;
}
int main(void){
F_word;
cin >> n >> m;
for(int i = 0; i < n; ++i) cin >> a[i];
for(int i = 0; i < m; ++i) cin >> b[i];
sort(a, a+n); sort(b, b+m);
cout << lower() << endl;
}
Compilation message
cipele.cpp: In function 'bool check(ll)':
cipele.cpp:20:8: warning: unused variable 'cnt' [-Wunused-variable]
20 | ll cnt = 0;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
352 ms |
3404 KB |
Output is correct |
2 |
Correct |
373 ms |
3660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
400 ms |
3668 KB |
Output is correct |
2 |
Correct |
398 ms |
3660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
368 KB |
Output is correct |
2 |
Correct |
9 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
336 KB |
Output is correct |
2 |
Correct |
9 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
332 KB |
Output is correct |
2 |
Correct |
18 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
332 KB |
Output is correct |
2 |
Correct |
13 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
336 KB |
Output is correct |
2 |
Correct |
10 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
294 ms |
3024 KB |
Output is correct |
2 |
Correct |
208 ms |
2236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
303 ms |
3288 KB |
Output is correct |
2 |
Correct |
298 ms |
2580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
265 ms |
2956 KB |
Output is correct |
2 |
Correct |
346 ms |
3088 KB |
Output is correct |