Submission #98956

#TimeUsernameProblemLanguageResultExecution timeMemory
98956SecretAgent007Cipele (COCI18_cipele)C++17
90 / 90
72 ms3284 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define INF 1e18 vector<int> a; vector<int> b; bool check(int x){ int p = 1; for(int i = 1; i < a.size(); i++){ while(p < b.size() && abs(b[p]-a[i]) > x){ p++; } if(p >= b.size()) return false; p++; } return true; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; a.resize(n+1); b.resize(m+1); for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= m; i++){ cin >> b[i]; } sort(a.begin()+1, a.end()); sort(b.begin()+1, b.end()); if(n > m){ swap(a,b); swap(n,m); } int l = 0; int r = INF; while(l < r){ int mid = (l+r)>>1; if(check(mid)){ r = mid; }else{ l = mid+1; } } cout << l << endl; }

Compilation message (stderr)

cipele.cpp: In function 'bool check(long long int)':
cipele.cpp:12:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i < a.size(); i++){
                    ~~^~~~~~~~~~
cipele.cpp:13:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(p < b.size() && abs(b[p]-a[i]) > x){
               ~~^~~~~~~~~~
cipele.cpp:16:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(p >= b.size()) return false;
            ~~^~~~~~~~~~~
#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...