# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146179 | 2019-08-22T17:04:22 Z | fabjanm | Cipele (COCI18_cipele) | C++ | 179 ms | 3240 KB |
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<cmath> using namespace std; int n,m; vector<int>lef; vector<int>righ; void input(){ cin>>n>>m; int br; for(int i=0;i<n;i++){ cin>>br; lef.push_back(br); } for(int i=0;i<m;i++){ cin>>br; righ.push_back(br); } //cout<<lef.size()<<" "<<righ.size()<<endl; } bool prov(int ruz){ if(lef.size()<=righ.size()){ int pos=0; for(int i=0;i<righ.size();i++){ //cout<<pos<<" -----> "<<lef[pos]<<" "<<righ[i]<<endl; if(pos==lef.size())return true; if(abs(lef[pos]-righ[i])<=ruz)pos++; } if(pos!=lef.size())return false; else return true; } else{ int pos=0; for(int i=0;i<lef.size();i++){ if(pos==righ.size())return true; if(abs(righ[pos]-lef[i])<=ruz)pos++; } if(pos!=righ.size())return false; else return true; } } void solve(){ sort(lef.begin(),lef.end()); sort(righ.begin(),righ.end()); int lo=0,hi=1000000000; while(lo<hi){ int mid=(lo+hi)/2; ///cout<<mid<<"->>>>>>>>"<<endl; if(prov(mid)){ hi=mid; } else{ lo=mid+1; } //cout<<lo<<" --> "<<hi<<endl<<endl; } cout<<lo; } int main(){ input(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 147 ms | 3048 KB | Output is correct |
2 | Correct | 177 ms | 3056 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 175 ms | 3240 KB | Output is correct |
2 | Correct | 179 ms | 3184 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 380 KB | Output is correct |
2 | Correct | 11 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 12 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 376 KB | Output is correct |
2 | Correct | 11 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 376 KB | Output is correct |
2 | Correct | 11 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 376 KB | Output is correct |
2 | Correct | 11 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 145 ms | 2800 KB | Output is correct |
2 | Correct | 101 ms | 1936 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 157 ms | 2876 KB | Output is correct |
2 | Correct | 107 ms | 2316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 142 ms | 2772 KB | Output is correct |
2 | Correct | 152 ms | 2900 KB | Output is correct |