Submission #166423

#TimeUsernameProblemLanguageResultExecution timeMemory
166423tincamateiCipele (COCI18_cipele)C++14
0 / 90
985 ms112092 KiB
#include <bits/stdc++.h> using namespace std; vector<int> v1, v2; bool check(int T) { int j = 0; for(int i = 0; i < v1.size(); ++i) { while(j < v2.size() && abs(v2[j] - v1[i]) > T) ++j; printf("%d[%d] <-> %d[%d]\n", v1[i], i, v2[j], j); if(j == v2.size()) return false; ++j; } return true; } int main() { int n, m, x; scanf("%d%d", &n, &m); for(int i = 0; i < n; ++i) { scanf("%d", &x); v1.push_back(x); } for(int i = 0; i < m; ++i) { scanf("%d", &x); v2.push_back(x); } if(v1.size() > v2.size()) v1.swap(v2); sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); int st = -1, dr = 1000000001; while(dr - st > 1) { int mid = (st + dr) / 2; if(check(mid)) dr = mid; else st = mid; } printf("%d", dr); return 0; }

Compilation message (stderr)

cipele.cpp: In function 'bool check(int)':
cipele.cpp:9:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < v1.size(); ++i) {
                  ~~^~~~~~~~~~~
cipele.cpp:10:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(j < v2.size() && abs(v2[j] - v1[i]) > T)
           ~~^~~~~~~~~~~
cipele.cpp:13:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(j == v2.size())
        ~~^~~~~~~~~~~~
cipele.cpp: In function 'int main()':
cipele.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &m);
   ~~~~~^~~~~~~~~~~~~~~~
cipele.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &x);
     ~~~~~^~~~~~~~~~
cipele.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &x);
     ~~~~~^~~~~~~~~~
#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...