# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
894364 |
2023-12-28T07:16:14 Z |
vjudge1 |
Cipele (COCI18_cipele) |
C++17 |
|
45 ms |
2888 KB |
#include <bits/stdc++.h>
#define ll long long
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ull unsigned long long
#define ld long double
#define lv v+v
#define rv v+v+1
#define files freopen("expert.in", "r", stdin), freopen("expert.out", "w", stdout)
using namespace std;
const ll mod = 1e9 + 7;
const ll N = 1e5 + 10;
const ll P = 337ll;
const ld EPS = 1e-9;
const ll block = 450;
ll n,m,a[N],b[N];
bool check(ll t) {
queue <ll> q;
for(ll i = 1; i<=n; i++) {
q.push(a[i]);
}
ll idx = 1, cnt= 0;
while(!q.empty() && idx <= m) {
ll cur = q.front();
if(abs(cur - b[idx]) <= t) {
cnt++;
idx++;
}
else if(cur >= b[idx]) {
idx++;
continue;
}
q.pop();
}
return cnt==min(n,m);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>m;
for(ll i = 1; i<=n; ++i) {
cin>>a[i];
}
for(ll i = 1; i<=m; i++) {
cin>>b[i];
}
sort(a+1, a+1+n);
sort(b+1, b+1+m);
ll l = -1, r = 1e9;
while(l + 1 < r) {
ll mid = l + r >> 1LL;
if(check(mid)) {
r = mid;
}
else {
l = mid;
}
}
cout<<r;
return 0;
}
// equal, min, max, 1, random, build
/*
2 3
11 11
10 10 12
*/
Compilation message
cipele.cpp: In function 'int main()':
cipele.cpp:55:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
55 | ll mid = l + r >> 1LL;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
2816 KB |
Output is correct |
2 |
Correct |
39 ms |
2820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
45 ms |
2888 KB |
Output is correct |
2 |
Correct |
39 ms |
2888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
2256 KB |
Output is correct |
2 |
Correct |
26 ms |
1852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
2524 KB |
Output is correct |
2 |
Correct |
21 ms |
2332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
2244 KB |
Output is correct |
2 |
Correct |
36 ms |
2584 KB |
Output is correct |