Submission #627435

#TimeUsernameProblemLanguageResultExecution timeMemory
627435Farhan_HYCipele (COCI18_cipele)C++14
90 / 90
840 ms8468 KiB
#include <bits/stdc++.h> #define int long long #define float double #define pb push_back #define F first #define S second #define T int t; cin >> t; while(t--) #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; /// Benzema is the best player in the world const int inf = 8e18; const int N = 1e5 + 5; const int M = 1e3 + 3; const int LOG = 31; const int mod = 1e9 + 7; const float pi = atan(1) * 4; int a[N], b[N], n, m; multiset<int> st; bool ok(int mid) { st.clear(); for(int i = 1; i <= m; i++) st.insert(b[i]); bool ret = 1; for(int i = 1; i <= n; i++) { int need = a[i] - mid; auto it = st.lower_bound(need); ret &= it != st.end(); if (it != st.end()) { ret &= abs(a[i] - *it) <= mid; st.erase(it); } } return ret; } main() { IOS cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int j = 1; j <= m; j++) cin >> b[j]; if (n > m) swap(n, m), swap(a, b); sort(a, a + n + 1); int l = 0, r = 1e9; while(l < r) { int mid = (l + r) / 2; if (ok(mid)) r = mid; else l = mid + 1; } cout << r; } ///use scanf

Compilation message (stderr)

cipele.cpp:41:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   41 | main()
      | ^~~~
#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...