Submission #384281

# Submission time Handle Problem Language Result Execution time Memory
384281 2021-04-01T08:00:31 Z AdiZer0 Cipele (COCI18_cipele) C++17
27 / 90
1000 ms 2924 KB
#include <bits/stdc++.h>

#define pb push_back
#define whole(x) x.begin(), x.end()
#define sz(x) (int)x.size()

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
const ll linf = (ll)1e18 + 1;

int a[N], b[N];

int main() {
    int n, m; scanf ("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
    for (int i = 1; i <= m; ++i) scanf ("%d", b + i);
    if (n > m)  {
        for (int i = 1; i <= n; ++i) swap(a[i], b[i]);
        swap(n, m);
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + m + 1);
    int ans = INF;
    for (int i = 1; i <= m - n + 1; ++i) { 
        int cur = 0;
        for (int p = 1; p <= n; ++p) cur = max(cur, abs(a[p] - b[i + p - 1]));
        ans = min(ans, cur);
    }
    printf ("%d\n", ans);
    return 0;
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:19:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |     int n, m; scanf ("%d %d", &n, &m);
      |               ~~~~~~^~~~~~~~~~~~~~~~~
cipele.cpp:20:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     for (int i = 1; i <= n; ++i) scanf ("%d", a + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
cipele.cpp:21:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |     for (int i = 1; i <= m; ++i) scanf ("%d", b + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2668 KB Output is correct
2 Correct 48 ms 2924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2924 KB Output is correct
2 Correct 48 ms 2924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 2560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 931 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1092 ms 2412 KB Time limit exceeded
2 Halted 0 ms 0 KB -