답안 #227886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227886 2020-04-29T06:47:20 Z kartel Cipele (COCI18_cipele) C++14
0 / 90
93 ms 2040 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define N +100500
#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;

ll a[N], b[N], n, m, i, j, l, r;

bool gd(ll x)
{
    int i, j = 1, cur = 0;
    for (i = 1; i <= n; i++)
    {
        while (j <= m && abs(a[i] - b[j]) > x) j++;
        if (j > m) return 0;
    }
    return 1;
}

int main()
{
    srand(time(0));
    ios_base::sync_with_stdio(0);
    iostream::sync_with_stdio(0);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

//    in("sum.in");
//    out("output.txt");

    cin >> n >> m;
    for (i = 1; i <= n; i++)
    {
        if (n < m) cin >> a[i];
              else cin >> b[i];
    }

    for (i = 1; i <= m; i++)
    {
        if (n < m) cin >> b[i];
              else cin >> a[i];
    }

    if (n > m) swap(n, m);

    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + m);

    l = 0;
    r = 1e18;

    while (l < r)
    {
        ll md = (l + r) / 2;

        if (gd(md)) r = md;
               else l = md + 1;
    }
    cout << l;
}



// 119 78 175 411

Compilation message

cipele.cpp: In function 'bool gd(ll)':
cipele.cpp:28:19: warning: unused variable 'cur' [-Wunused-variable]
     int i, j = 1, cur = 0;
                   ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 1912 KB Output is correct
2 Incorrect 88 ms 1912 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 93 ms 2040 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 7 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 7 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 1656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 86 ms 1784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 66 ms 1536 KB Output isn't correct
2 Halted 0 ms 0 KB -