Submission #894355

#TimeUsernameProblemLanguageResultExecution timeMemory
894355vjudge1Cipele (COCI18_cipele)C++17
45 / 90
39 ms5868 KiB
#include <bits/stdc++.h> #define ll long long #define all(a) a.begin(), a.end() #define F first #define S second #define pb push_back #define eb emplace_back #define ull unsigned long long #define ld long double #define lv v+v #define rv v+v+1 #define files freopen("expert.in", "r", stdin), freopen("expert.out", "w", stdout) using namespace std; const ll mod = 1e9 + 7; const ll N = 1e5 + 10; const ll P = 337ll; const ld EPS = 1e-9; const ll block = 450; ll n,m,a[N],b[N]; queue <ll> q; bool check(ll t) { for(ll i = 1; i<=n; i++) { q.push(a[i]); } ll idx = 1, cnt= 0; while(!q.empty() && idx <= m) { ll cur = q.front(); // cout<<cur<<" "<<b[idx]<<"\n"; if(abs(cur - b[idx]) <= t) { cnt++; idx++; } else if(cur >= b[idx]) { idx++; continue; } q.pop(); } // cout<<t<<"\n\n\n"; return cnt>=min(n,m); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin>>n>>m; for(ll i = 1; i<=n; ++i) { cin>>a[i]; } for(ll i = 1; i<=m; i++) { cin>>b[i]; } sort(a+1, a+1+n); sort(b+1, b+1+m); ll l = -1, r = 1e9; while(l + 1 < r) { ll mid = l + r >> 1LL; if(check(mid)) { r = mid; } else { l = mid; } } cout<<r; return 0; } // equal, min, max, 1, random, build /* 5 5 7 6 1 2 10 9 11 6 3 12 4 3 2 39 41 45 39 42 46 */

Compilation message (stderr)

cipele.cpp: In function 'int main()':
cipele.cpp:58:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   58 |     ll mid = l + r >> 1LL;
      |              ~~^~~
#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...