# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
894276 |
2023-12-28T03:24:15 Z |
vjudge1 |
Cipele (COCI18_cipele) |
C++17 |
|
32 ms |
1884 KB |
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"
const ld PI = 3.1415926535;
const int N = 5e3 + 2;
const int M = 7e6 + 1;
int mod = 1e9+7;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;
const int P = 31;
int mult(int a, int b) {
return a * 1LL * b % mod;
}
int sum(int a, int b) {
a %= mod;
if (a + b < 0)
return a + b + mod;
if (a + b >= mod)
return a + b - mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0)
return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % mod;
} else {
ll b = binpow(a, n / 2);
return b * b % mod;
}
}
int n, m;
vector<int> a, b;
bool f(int mx){
int l = 1, r = 1;
bool ok = true;
for(; l <= n; l++, r++){
while(r <= m && abs(a[l] - b[r]) > mx)
r++;
if(r > m)
ok = false;
}
return ok;
}
void solve(){
cin >> n >> m;
a.resize(n + 1);
b.resize(m + 1);
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 1; i <= m; i++)
cin >> b[i];
if(n > m){
swap(a, b);
swap(n, m);
}
sort(all(a));
sort(all(b));
int lo = -1, hi = 1e9+7;
while(lo + 1 < hi){
int m = (lo + hi) / 2;
if(f(m))
hi = m;
else
lo = m;
}
cout << hi << '\n';
}
signed main() {
mispertion;
int t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1880 KB |
Output is correct |
2 |
Correct |
31 ms |
1880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1884 KB |
Output is correct |
2 |
Correct |
31 ms |
1884 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
540 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 |
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 |
2 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 |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
1628 KB |
Output is correct |
2 |
Correct |
18 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
1628 KB |
Output is correct |
2 |
Correct |
15 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
1624 KB |
Output is correct |
2 |
Correct |
27 ms |
1780 KB |
Output is correct |