Submission #681504

# Submission time Handle Problem Language Result Execution time Memory
681504 2023-01-13T08:13:13 Z Vladth11 Cipele (COCI18_cipele) C++14
0 / 90
1000 ms 2064 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 = 1000001;
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)
{
    int maxim = 0;
    for(int i = 1; i <= m; i++){
        maxim = max(maxim, abs(a[i + poz - 1] - b[i]));
    }
    return maxim;
}
 
int ternary(int st, int dr){
    if(st == dr - 1)
        return min(f(st), f(dr));
    int mid1 = st + (dr - st) / 3;
    int mid2 = dr - (dr - st) / 3;
    int f1 = f(mid1);
    int f2 = f(mid2);
    if(f1 < f2)
        return ternary(st, f2 - 1);
    return ternary(f1 + 1, dr);
}
 
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);
    }
    cout << ternary(1, n - m + 1);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 27 ms 1964 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 2064 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1093 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 2008 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 1956 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 26 ms 1864 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -