Submission #1070060

#TimeUsernameProblemLanguageResultExecution timeMemory
1070060vjudge1Sprinklers (CEOI24_sprinklers)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; long long int s[n]; long long int f[m]; for(int i = 0; i < n; i++){ cin >> s[i]; } long long int ans = -1; for(int i = 0; i < m; i++){ cin >> f[i]; int ans1 = -1; int l = 0; int r = n - 1; while(l <= r){ int mid = (l + r) / 2; if(s[mid] <= f[i]){ ans1 = max(ans1, mid); l = mid + 1; }else{ r = mid - 1; } } long long int mini = 1e18; if(ans1 != -1){ mini = f[i] - s[ans1]; } int ans2 = n + 1; l = 0; r = n - 1; while(l <= r){ int mid = (l + r) / 2; if(s[mid] >= f[i]){ ans2 = min(ans2, mid); r = mid - 1; }else{ l = mid + 1; } } if(ans2 != (n + 1)){ mini = min(mini, s[ans2] - f[i]); } ans = max(ans, mini); } cout << ans; }
#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...