Submission #384318

# Submission time Handle Problem Language Result Execution time Memory
384318 2021-04-01T10:43:15 Z AdiZer0 Cipele (COCI18_cipele) C++17
18 / 90
1000 ms 1408 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 used[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 = 0;
    for (int i = 1; i <= n; ++i) { 
        int pos = -1;
        for (int j = 1; j <= m; ++j) { 
            if (used[j]) continue;
            if (pos == -1 || abs(a[i] - b[j]) < abs(a[i] - b[pos])) pos = j;
        }
        ans = max(ans, abs(a[i] - b[pos]));
        used[pos] = 1;
    }
    printf ("%d\n", ans);
    return 0;
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:20:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     int n, m; scanf ("%d %d", &n, &m);
      |               ~~~~~~^~~~~~~~~~~~~~~~~
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 <= n; ++i) scanf ("%d", a + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
cipele.cpp:22:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |     for (int i = 1; i <= m; ++i) scanf ("%d", b + i);
      |                                  ~~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 1388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 1232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 364 KB Output is correct
2 Correct 81 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 364 KB Output is correct
2 Correct 80 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 424 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 69 ms 420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 1408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1038 ms 1004 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 1004 KB Time limit exceeded
2 Halted 0 ms 0 KB -