답안 #227888

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227888 2020-04-29T07:00:17 Z Vimmer Cipele (COCI18_cipele) C++14
0 / 90
69 ms 11640 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define M ll(1e9 + 7)

using namespace std;

//using namespace __gnu_pbds;

typedef long double ld;

typedef long long ll;

typedef short int si;

//typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;




int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m;

    cin >> n >> m;

    vector <int> g(n), v(m);

    for (int i = 0; i < n; i++) cin >> g[i];

    for (int i = 0; i < m; i++) cin >> v[i];

    if (n > m) {swap(g, v); swap(n, m);}

    set <int> se; se.clear();

    for (auto it : v) se.insert(it);

    assert(sz(se) == m);

    sort(g.begin(), g.end());

    int ans = 0;

    for (auto it : g)
    {
        auto itr = se.upper_bound(it);

        if (itr == se.begin())
        {
            ans = max(ans, abs(*itr - it));

            se.erase(itr);

            continue;
        }

        auto j = itr; j--;

        if (abs(*itr - it) == abs(*j - it)) {ans = max(ans, abs(*j - it)); se.erase(j); continue;}

        if (abs(*itr - it) < abs(*j - it))
        {
            ans = max(ans, abs(*itr - it));

            se.erase(itr);

            continue;
        } else {ans = max(ans, abs(*j - it)); se.erase(j); continue;}

    }

    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 5884 KB Output is correct
2 Runtime error 67 ms 11640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 69 ms 11640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Runtime error 7 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 7 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 59 ms 10872 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 62 ms 10872 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 58 ms 10488 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -