Submission #146395

#TimeUsernameProblemLanguageResultExecution timeMemory
146395badrovinhoCipele (COCI18_cipele)C++14
90 / 90
166 ms2952 KiB
#include <iostream> #include <bits/stdc++.h> #include <algorithm> #include <vector> #include <string> #include <cstring> using namespace std; int l[100005]; int r[100005]; int main (){ int n,m; cin >> n >> m; for (int i = 0; i < n; i++){ cin >> l[i]; } for (int i = 0; i < m; i++){ cin >> r[i]; } sort(l, l + n); sort(r, r + m); int lo = 0; int hi = 1000000000; int mid = hi / 2; while (lo != hi){ if (n > m){ int raz = n - m; int ptl = 0; int ptr = 0; int sol = true; for (int i = 0; i < m; i++){ while (raz && abs(l[ptl] - r[i]) > mid) { raz--; ptl++; } if (abs(l[ptl] - r[i]) > mid) { sol = false; break; } ptl++; } if (!sol){ lo = mid+1; mid = (hi+lo)/2; }else { hi = mid; mid = (hi+lo)/2; } } else { int raz = m - n; int ptl = 0; int ptr = 0; int sol = true; for (int i = 0; i < n; i++){ while (raz && abs(l[i] - r[ptr]) > mid) { raz--; ptr++; } if (abs(l[i] - r[ptr]) > mid) { sol = false; break; } ptr++; } if (!sol){ lo = mid+1; mid = (hi+lo)/2; }else { hi = mid; mid = (hi+lo)/2; } } // cout << "srednji mid je --> " << mid << endl; } cout << mid; return 0; }

Compilation message (stderr)

cipele.cpp: In function 'int main()':
cipele.cpp:38:8: warning: unused variable 'ptr' [-Wunused-variable]
    int ptr = 0;
        ^~~
cipele.cpp:61:8: warning: unused variable 'ptl' [-Wunused-variable]
    int ptl = 0;
        ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...