답안 #1046026

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046026 2024-08-06T09:07:20 Z VahanAbraham Sprinklers (CEOI24_sprinklers) C++17
6 / 100
17 ms 4700 KB
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
#include <bitset>
#include <cmath>
#include <vector>
#include <iomanip>
#include <random>
#include <chrono>
#include <cassert>

using namespace std;

#define ll long long
#define fr first
#define sc second
#define pb push_back
#define US freopen(".in", "r", stdin); freopen("j.out", "w", stdout);

ll gcd(ll a, ll b)
{
    if (a == 0 || b == 0) {
        return  max(a, b);
    }
    if (a <= b) {
        return gcd(a, b % a);
    }
    else {
        return gcd(a % b, b);
    }
}
ll lcm(ll a, ll b) {
    return (a / gcd(a, b)) * b;
}

const int N = 200005;
const ll oo = 100000000000000000, MOD = 1000000007;

int n, m;
ll f[N], s[N];

void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> s[i];
    }
    for (int i = 1; i <= m; ++i) {
        cin >> f[i];
    }
    ll ans = 0;
    for (int i = 1; i <= m; ++i) {
        int l = 1, r = n;
        ll distl = oo, distr = oo;
        while (l <= r) {
            int mid = (l + r) / 2;
            if (s[mid] <= f[i]) {
                distl = f[i] - s[mid];
                l = mid + 1;
            }
            else {
                r = mid - 1;
            }
        }
        l = 1, r = n;
        while (l <= r) {
            int mid = (l + r) / 2;
            if (s[mid] >= f[i]) {
                distr = s[mid] - f[i];
                r = mid - 1;
            }
            else {
                l = mid + 1;
            }
        }
        ans = max(ans, min(distl, distr));
    }
    if (ans == oo) {
        cout << -1 << endl;
        return;
    }
    cout << ans << endl;
    for (int i = 1; i <= n; i += 3) {
        cout << "LRR";
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //US
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Correct
2 Incorrect 0 ms 2396 KB Incorrect string length
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2396 KB Incorrect string length
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Correct
2 Correct 7 ms 2524 KB Correct
3 Correct 1 ms 2396 KB Correct
4 Correct 16 ms 2908 KB Correct
5 Correct 17 ms 2904 KB Correct
6 Correct 1 ms 2396 KB Correct
7 Correct 0 ms 2396 KB Correct
8 Correct 13 ms 2904 KB Correct
9 Correct 15 ms 4700 KB Correct
10 Correct 17 ms 4700 KB Correct
11 Correct 6 ms 3672 KB Correct
12 Correct 10 ms 3928 KB Correct
13 Correct 12 ms 3768 KB Correct
14 Correct 13 ms 3932 KB Correct
15 Correct 13 ms 4176 KB Correct
16 Correct 11 ms 3676 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Correct
2 Incorrect 0 ms 2396 KB Incorrect string length
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Correct
2 Incorrect 9 ms 2652 KB Incorrect string length
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Correct
2 Incorrect 0 ms 2396 KB Incorrect string length
3 Halted 0 ms 0 KB -