diff --git a/Luogu/P7514/P7514.cpp b/Luogu/P7514/P7514.cpp new file mode 100644 index 00000000..f50d2dc6 --- /dev/null +++ b/Luogu/P7514/P7514.cpp @@ -0,0 +1,28 @@ +#include +#include + +using std::cin; +using std::cout; +using std::endl; + +const int N = 1000005; + +int n, m, a[N], b[N]; + +int main() { + cin >> n >> m; + for (int i = 1; i <= n; i++) { + cin >> a[i]; + } + for (int i = 1; i <= n; i++) { + cin >> b[i]; + } + int min = std::numeric_limits::max(), + max = std::numeric_limits::min(); + for (int i = 1; i <= n; i++) { + min = std::min(min, std::max(a[i], b[i])); + max = std::max(max, std::min(a[i], b[i])); + } + cout << max - min << endl; + return 0; +}