답안 #1069906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069906 2024-08-22T09:56:17 Z vjudge1 Sprinklers (CEOI24_sprinklers) C++17
26 / 100
2000 ms 3552 KB
#include <bits/stdc++.h>
#define div /
#define ll long long

#define fore(i, l, r) for(int i=int(l); i<int(r); i++)
#define sz(a) int((a).size())

using namespace std;

const int INF = 1e9;
const int MX = 5e5 + 23;
const int MOD = 1000000007;
const int MAX_N = 5e5+23;
const int N = 1e6;

void solve() {
    int n,m;
    cin >> n >> m;
    int s[n],f[m],ans=INF,ok=1;
    string ansString;
    fore(i,0,n)
        cin >> s[i];
    fore(i,0,m)
        cin >> f[i];
    vector<int>v;
    for(int i=0; i<n; i+=3) {
        if(s[i] != s[i+1] or s[i+1] != s[i+2])
            ok=0;
        v.push_back(s[i]);
    }
    if(ok) {
        ans=0;
        sort(v.begin(), v.end());
        fore(i,0,m) {
            int tmp=INF;
            auto itr = lower_bound(v.begin(), v.end(), f[i]);
            tmp = min(tmp, abs(f[i]-(*itr)));
            if(itr - v.begin() > 0) {
                itr--;
                tmp = min(tmp,abs(f[i]-(*itr)));
            }
            ans = max(ans,tmp);
        }
        cout << ans << endl;
        fore(i,0,n div 3)
            cout << "RRL";
        cout << endl;
        return;
    }
    fore(p,0,1024) {
        string tmp;
        fore(j,0,n) {
            tmp+='R';
            if((1 << j) & p)
                tmp[j] = 'L';
        }
        int k=0;
        fore(i,0,m) {
            int tmpK=INF;
            fore(j,0,n) {
                if(tmp[j] == 'L' and f[i] <= s[j])
                    tmpK=min(tmpK,abs(s[j]-f[i]));
                if(tmp[j] == 'R' and f[i] >= s[j])
                    tmpK=min(tmpK,abs(s[j]-f[i]));
            }
            k = max(k,tmpK);
        }
        if(k < ans) {
            ans = k;
            ansString = tmp;
        }
    }
    if(ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl << ansString << endl;
}

int main() {
    ios::sync_with_stdio(false);

    int t=1;
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 456 KB Correct
2 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 160 ms 1372 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 213 ms 1584 KB Correct
5 Correct 191 ms 1372 KB Correct
6 Correct 0 ms 344 KB Correct
7 Correct 1 ms 348 KB Correct
8 Correct 38 ms 604 KB Correct
9 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 456 KB Correct
2 Correct 13 ms 1524 KB Correct
3 Correct 1 ms 604 KB Correct
4 Correct 18 ms 3424 KB Correct
5 Correct 19 ms 3548 KB Correct
6 Correct 1 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 18 ms 3528 KB Correct
9 Correct 18 ms 3528 KB Correct
10 Correct 19 ms 3552 KB Correct
11 Correct 9 ms 2136 KB Correct
12 Correct 13 ms 2136 KB Correct
13 Correct 19 ms 2528 KB Correct
14 Correct 18 ms 2648 KB Correct
15 Correct 14 ms 2904 KB Correct
16 Correct 13 ms 2392 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 456 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 8 ms 456 KB Correct
4 Correct 3 ms 344 KB Correct
5 Correct 11 ms 348 KB Correct
6 Correct 14 ms 464 KB Correct
7 Correct 1 ms 344 KB Correct
8 Correct 11 ms 472 KB Correct
9 Correct 11 ms 348 KB Correct
10 Correct 11 ms 468 KB Correct
11 Correct 2 ms 348 KB Correct
12 Correct 11 ms 472 KB Correct
13 Correct 11 ms 348 KB Correct
14 Correct 3 ms 344 KB Correct
15 Correct 8 ms 348 KB Correct
16 Correct 8 ms 348 KB Correct
17 Correct 7 ms 456 KB Correct
18 Correct 8 ms 456 KB Correct
19 Correct 5 ms 344 KB Correct
20 Correct 3 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 456 KB Correct
2 Execution timed out 2041 ms 1624 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 456 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 160 ms 1372 KB Correct
4 Correct 1 ms 344 KB Correct
5 Correct 213 ms 1584 KB Correct
6 Correct 191 ms 1372 KB Correct
7 Correct 0 ms 344 KB Correct
8 Correct 1 ms 348 KB Correct
9 Correct 38 ms 604 KB Correct
10 Correct 0 ms 348 KB Correct
11 Correct 13 ms 1524 KB Correct
12 Correct 1 ms 604 KB Correct
13 Correct 18 ms 3424 KB Correct
14 Correct 19 ms 3548 KB Correct
15 Correct 1 ms 348 KB Correct
16 Correct 0 ms 348 KB Correct
17 Correct 18 ms 3528 KB Correct
18 Correct 18 ms 3528 KB Correct
19 Correct 19 ms 3552 KB Correct
20 Correct 9 ms 2136 KB Correct
21 Correct 13 ms 2136 KB Correct
22 Correct 19 ms 2528 KB Correct
23 Correct 18 ms 2648 KB Correct
24 Correct 14 ms 2904 KB Correct
25 Correct 13 ms 2392 KB Correct
26 Correct 8 ms 456 KB Correct
27 Correct 3 ms 344 KB Correct
28 Correct 11 ms 348 KB Correct
29 Correct 14 ms 464 KB Correct
30 Correct 1 ms 344 KB Correct
31 Correct 11 ms 472 KB Correct
32 Correct 11 ms 348 KB Correct
33 Correct 11 ms 468 KB Correct
34 Correct 2 ms 348 KB Correct
35 Correct 11 ms 472 KB Correct
36 Correct 11 ms 348 KB Correct
37 Correct 3 ms 344 KB Correct
38 Correct 8 ms 348 KB Correct
39 Correct 8 ms 348 KB Correct
40 Correct 7 ms 456 KB Correct
41 Correct 8 ms 456 KB Correct
42 Correct 5 ms 344 KB Correct
43 Correct 3 ms 348 KB Correct
44 Execution timed out 2041 ms 1624 KB Time limit exceeded
45 Halted 0 ms 0 KB -