Submission #227885

# Submission time Handle Problem Language Result Execution time Memory
227885 2020-04-29T06:44:58 Z Vimmer Cipele (COCI18_cipele) C++14
18 / 90
49 ms 1152 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);}

    int k = m - n;

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

    int j = 0, ans = 0;

    for (int i = 0; i < n; i++)
    {
        if (k == 0 || j + 1 == m) {ans = max(ans, abs(g[i] - v[j])); j++; continue;}

        if (abs(g[i] - v[j]) > abs(v[j + 1] - g[i]))
        {
            k--;

            j++;

            i--;

            continue;
        }
    }

    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1152 KB Output is correct
2 Correct 48 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1152 KB Output is correct
2 Correct 49 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 7 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 1024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 1024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -