Submission #1128395

#TimeUsernameProblemLanguageResultExecution timeMemory
1128395pemguimnSprinklers (CEOI24_sprinklers)C++17
9 / 100
48 ms2120 KiB
#include <bits/stdc++.h> #define pii pair<int, int> #define int long long using namespace std; const int N = 1e5 + 5; int n, m, a[N], b[N]; string dir, fin; bool check(int x){ dir = ""; int d = 0; for(int i = 1; i <= n; i++){ if(d == m) {dir += 'L'; continue;} if(b[d + 1] < a[i]){ dir += 'L'; while(d < m && b[d + 1] >= a[i] - x && b[d + 1] <= a[i]) d++; } else{ dir += 'R'; while(d < m && b[d + 1] >= a[i] && b[d + 1] <= a[i] + x) d++; } } return d == m; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); #define task "sprinklers" if(fopen(task ".inp", "r")){ freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= m; i++) cin >> b[i]; int lo = 0, hi = 1e9, ans = -1; while(lo <= hi){ int mid = (lo + hi) / 2; if(check(mid)) ans = mid, hi = mid - 1, fin = dir; else lo = mid + 1; } cout << ans << '\n' << fin; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen(task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:33:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#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...