Submission #1070063

#TimeUsernameProblemLanguageResultExecution timeMemory
1070063vjudge1Sprinklers (CEOI24_sprinklers)C++17
26 / 100
92 ms2136 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; if(n > 10){ 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 << endl; for(int i = 0; i < n; i++){ if(i % 3 == 0 or i % 3 == 2){ cout << "R"; }else{ cout << "L"; } } }else{ long long int s[n]; long long int f[m]; for(int i = 0; i < n; i++){ cin >> s[i]; } for(int i = 0; i < m; i++){ cin >> f[i]; } long long int ans = 1e18; long long int INF = 1e18; int br1[n]; for(int k = 0; k < (1 << n); k++){ int br[n]; for(int j = 0; j < n; j++){ br[j] = 0; } int k1 = k; int brojac = 0; while(k1 > 0){ if(k1 % 2 == 1){ br[brojac]++; } brojac++; k1 = k1 / 2; } long long int res = 0; for(int i = 0; i < m; i++){ long long int mini = 1e18; for(int j = 0; j < n; j++){ if(br[j] == 0){ if(s[j] <= f[i]){ mini = min(mini, f[i] - s[j]); } }else{ if(s[j] >= f[i]){ mini = min(mini, s[j] - f[i]); } } } res = max(res, mini); } if(res < ans){ ans = min(ans, res); for(int j = 0; j < n; j++){ br1[j] = br[j]; } } } if(ans == INF){ cout << -1; }else{ cout << ans <<endl; for(int i = 0; i < n; i++){ if(br1[i] == 0){ cout << "R"; }else{ cout << "L"; } } } } }
#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...