# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
681537 |
2023-01-13T09:28:32 Z |
Vladth11 |
Cipele (COCI18_cipele) |
C++14 |
|
429 ms |
5784 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
using namespace std;
typedef pair <int, int> pii;
typedef long long ll;
const int NMAX = 100001;
const int VMAX = 41;
const int INF = 1e9;
const int MOD = 1000000009;
const int BLOCK = 318;
const int base = 31;
const int nrbits = 21;
int a[NMAX], b[NMAX];
int n, m;
int f(int poz)
{
if(poz + m - 1 > n) return 1e9;
int maxim = 0;
for(int i = 1; i <= m; i++){
maxim = max(maxim, abs(a[i + poz - 1] - b[i]));
}
return maxim;
}
bool OK(int x){
set <int> st;
int i;
for(i = 1; i <= n; i++)
st.insert(a[i]);
for(i = 1; i <= m; i++){
int nou = b[i] - x;
auto it = st.lower_bound(nou);
if(it != st.end() && abs((*it) - b[i]) <= x){
st.erase(it);
continue;
}
nou = b[i] + x;
it = st.upper_bound(nou);
if(it == st.begin()) return 0;
it = prev(it);
if(it != st.end() && abs((*it) - b[i]) <= x){
st.erase(it);
continue;
}
return 0;
}
return 1;
}
int main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int i;
cin >> n >> m;
for(i = 1; i <= n; i++)
cin >> a[i];
for(i = 1; i <= m; i++)
cin >> b[i];
sort(a + 1, a + n + 1);
sort(b + 1, b + m + 1);
if(m > n){
for(i = 1; i <= m; i++){
swap(a[i], b[i]);
}
swap(n, m);
}
int r = 0;
int pas = (1 << 20);
while(pas){
if(!OK(r + pas))
r += pas;
pas /= 2;
}
if(!OK(r)) r++;
cout << r;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
429 ms |
5784 KB |
Output is correct |
2 |
Incorrect |
366 ms |
5676 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
387 ms |
5768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
468 KB |
Output is correct |
2 |
Incorrect |
10 ms |
600 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
468 KB |
Output is correct |
2 |
Incorrect |
11 ms |
860 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
596 KB |
Output is correct |
2 |
Incorrect |
10 ms |
596 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
414 ms |
5532 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
325 ms |
5408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
328 ms |
5196 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |