# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147063 | 2019-08-27T11:14:40 Z | albino_ojuz | Cipele (COCI18_cipele) | C++14 | 160 ms | 2080 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1e5+5; int n,m; int mini,maks; long long niz1[N],niz2[N]; bool f(int mid) { long long zas = 0; long long pom = 0,ad = 0; for (long long i = 0;i < n;i++) { for (long long j = i + ad;j < m;j++) { if (abs(niz1[i] - niz2[j]) <= mid) { //uspio sam uparit break; } if (j == m - 1) {//nisam ga naso uopce zas = 1; } pom++; } ad = pom; } if (zas == 1) { return false; } return true; } int main () { cin >> n >> m; for (long long i = 0;i < n;i++) { cin >> niz1[i]; if (niz1[i] > maks) { maks = niz1[i]; } if (niz1[i] < mini) { mini = niz1[i]; } } for (long long i = 0;i < m;i++) { cin >> niz2[i]; if (niz2[i] > maks) { maks = niz2[i]; } if (niz2[i] < mini) { mini = niz2[i]; } } sort(niz1,niz1 + n); sort(niz2,niz2 + m); // prvi je manji prvi je manji prvi je manji if (n > m) { for (long long i = 0;i < n;i++) { swap(niz1[i],niz2[i]); } swap(n,m); } long long lo = 0, hi = maks; while (lo != hi) { long long zas = 0; long long pom = 0,ad = 0; long long mid = (lo + hi) / 2; if (f(mid) == 1) { hi = mid; } else { lo = mid + 1; } } while(f(lo-1) == 1) { lo--; } while(f(lo) == 0) { lo++; } cout << lo << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 132 ms | 2080 KB | Output is correct |
2 | Correct | 160 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 160 ms | 1856 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 376 KB | Output is correct |
2 | Correct | 11 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 11 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 380 KB | Output is correct |
2 | Correct | 10 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 376 KB | Output is correct |
2 | Correct | 10 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 140 ms | 1652 KB | Output is correct |
2 | Correct | 94 ms | 1408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 146 ms | 1784 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 134 ms | 1528 KB | Output is correct |
2 | Incorrect | 136 ms | 1784 KB | Output isn't correct |