# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
516274 |
2022-01-21T01:32:15 Z |
thanh913 |
Cipele (COCI18_cipele) |
C++14 |
|
44 ms |
4320 KB |
#include <bits/stdc++.h>
using namespace std;
//types
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
//lowercase 31, all 53
//(P/Q) % M = (P % M) * (Q^(M-2) % M)
//----------------------------------------------------------------------------------------
const int mx = 1e5+5;
ll n, m;
vector<ll> a, b;
bool check(ll x) {
ll i = 1, j = 1;
while (i <= n && j <= m) {
while (j <= m) {
if (abs(a[i] - b[j]) <= x) {
j++;
break;
}
else {
j++;
if (j > m) return false;
}
}
i++;
//if (i < n && j > m) return false;
}
return true;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
//freopen("Shoes.Inp", "r", stdin);
//freopen("Shoes.Out", "w", stdout);
cin >> n >> m;
a.pb(-inf);
b.pb(-inf);
for (int i = 1; i <= n; i++) {
int tmp;
cin >> tmp;
a.pb(tmp);
}
for (int i = 1; i <= m; i++) {
int tmp;
cin >> tmp;
b.pb(tmp);
}
sort(a.begin()+1, a.end());
sort(b.begin()+1, b.end());
if (a.size() > b.size()) {
swap(a, b);
swap(n, m);
}
ll l = 0, r = 2e9, kq = 1e9;
while (l <= r) {
ll mid = (l+r) / 2;
if (check(mid)) {
kq = mid;
r = mid-1;
}
else {
l = mid+1;
}
}
cout << kq;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
4140 KB |
Output is correct |
2 |
Correct |
44 ms |
4320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
37 ms |
4180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
368 KB |
Output is correct |
2 |
Correct |
2 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
448 KB |
Output is correct |
2 |
Correct |
2 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
388 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
460 KB |
Output is correct |
2 |
Correct |
2 ms |
564 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
3652 KB |
Output is correct |
2 |
Correct |
22 ms |
2568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
4016 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
3672 KB |
Output is correct |
2 |
Incorrect |
31 ms |
4028 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |