# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
894315 |
2023-12-28T05:23:53 Z |
vjudge1 |
Cipele (COCI18_cipele) |
C++17 |
|
37 ms |
5876 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];
queue <ll> q;
bool check(ll t) {
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();
// cout<<cur<<" "<<b[idx]<<"\n";
if(abs(cur - b[idx]) <= t) {
cnt++;
idx++;
}
else if(cur >= b[idx]) {
idx++;
continue;
}
q.pop();
}
// cout<<t<<"\n\n\n";
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
/*
5 5
7 6 1 2 10
9 11 6 3 12
4 3
2 39 41 45
39 42 46
*/
Compilation message
cipele.cpp: In function 'int main()':
cipele.cpp:58:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
58 | ll mid = l + r >> 1LL;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
2648 KB |
Output is correct |
2 |
Correct |
36 ms |
2768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
2640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
2140 KB |
Output is correct |
2 |
Incorrect |
23 ms |
1876 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
5876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
2132 KB |
Output is correct |
2 |
Incorrect |
33 ms |
2392 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |