Submission #472516

#TimeUsernameProblemLanguageResultExecution timeMemory
472516HossamHero7Cipele (COCI18_cipele)C++14
90 / 90
154 ms2476 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' int n,m; vector <int> v1; vector <int> v2; bool valid(int dif){ int curStart = 0; for(int i=0;i<n;i++){ int idx = lower_bound(v2.begin()+curStart,v2.end(),v1[i]-dif) - v2.begin(); if(idx == m) return 0; if(abs(v2[idx] - v1[i]) > dif) return 0; curStart = idx + 1; } return 1; } void solve(){ cin>>n>>m; v1.resize(n); v2.resize(m); for(auto &i:v1) cin>>i; for(auto &i:v2) cin>>i; if(n>m){ swap(n,m); swap(v1,v2); } sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end()); int l=0; int r=1e9; int ans=0; while(l<=r){ int md = l + r >> 1; if(valid(md)){ ans = md; r = md - 1; } else l = md + 1; } cout<<ans<<endl; } int main() { int t=1; // cin>>t; while(t--){ solve(); } return 0; }

Compilation message (stderr)

cipele.cpp: In function 'void solve()':
cipele.cpp:35:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |         int md = l + r >> 1;
      |                  ~~^~~
#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...