답안 #1091151

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091151 2024-09-20T00:34:08 Z Pajaraja Sprinklers (CEOI24_sprinklers) C++17
26 / 100
95 ms 3536 KB
#include <bits/stdc++.h>
#define MAXN 100007
using namespace std;
string res;
bool bt[MAXN];
int s[MAXN],f[MAXN],n,m;
bool check(int k){
    res.clear();
    int d=0;
    for(int i=0;i<n;i++) {
        if(d==m) {
            res+='L';
            continue;
        }
        if(f[d]<s[i]) {
            if(f[d]<s[i]-k) return false;
            if(i!=n-1 && s[i+1]-k<=f[d] && bt[i])
            {
                res+="RL";
                while(d<m && f[d]<=s[i]+k) d++;
                i++;
                continue;
            }
            res+='L';
            while(d<m && f[d]<=s[i]) d++;
            continue;
        }
        if(f[d]>=s[i]){
            res+='R';
            while(d<m && f[d]<=s[i]+k) d++;
        }
    }
    if(d==m) return true;
    return false;
}
int binarna(int l,int r)
{
    if(l==r) return l;
    int s=(l+r)/2;
    if(check(s)) return binarna(l,s);
    return binarna(s+1,r);
}
int main() {
    cin>>n>>m;
    for(int i=0;i<n;i++) cin>>s[i];
    for(int i=0;i<m;i++) cin>>f[i];
    int d=-1;
    for(int i=0;i<m;i++) {
        while(d<n-1 && s[d+1]<=f[i]) d++;
        if(d>=0 && s[d]!=f[i]) bt[d]=true;
    }
    int ans=binarna(0,1000000000);
    if(!check(ans)) {
        cout<<-1;
        return 0;
    }
    cout<<ans<<endl<<res<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Correct
2 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 28 ms 1372 KB Correct
3 Correct 1 ms 348 KB Correct
4 Correct 25 ms 1744 KB Correct
5 Correct 25 ms 1740 KB Correct
6 Correct 1 ms 344 KB Correct
7 Correct 0 ms 344 KB Correct
8 Correct 6 ms 672 KB Correct
9 Correct 0 ms 344 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Correct
2 Correct 32 ms 1620 KB Correct
3 Correct 5 ms 600 KB Correct
4 Correct 64 ms 3440 KB Correct
5 Correct 70 ms 3408 KB Correct
6 Correct 0 ms 344 KB Correct
7 Correct 1 ms 348 KB Correct
8 Correct 56 ms 3460 KB Correct
9 Correct 56 ms 3412 KB Correct
10 Correct 62 ms 3408 KB Correct
11 Correct 33 ms 2132 KB Correct
12 Correct 38 ms 2140 KB Correct
13 Correct 58 ms 2388 KB Correct
14 Correct 57 ms 2664 KB Correct
15 Correct 52 ms 2896 KB Correct
16 Correct 40 ms 2384 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 1 ms 348 KB Correct
5 Correct 1 ms 348 KB Correct
6 Correct 1 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 1 ms 348 KB Correct
9 Correct 1 ms 348 KB Correct
10 Correct 1 ms 348 KB Correct
11 Correct 0 ms 348 KB Correct
12 Correct 1 ms 348 KB Correct
13 Correct 1 ms 348 KB Correct
14 Correct 1 ms 348 KB Correct
15 Correct 1 ms 348 KB Correct
16 Correct 1 ms 348 KB Correct
17 Correct 0 ms 348 KB Correct
18 Correct 1 ms 348 KB Correct
19 Correct 1 ms 348 KB Correct
20 Correct 1 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Correct
2 Correct 32 ms 1840 KB Correct
3 Correct 76 ms 3308 KB Correct
4 Correct 82 ms 3536 KB Correct
5 Correct 79 ms 3408 KB Correct
6 Correct 77 ms 3376 KB Correct
7 Correct 79 ms 3352 KB Correct
8 Correct 95 ms 3416 KB Correct
9 Correct 83 ms 3416 KB Correct
10 Correct 79 ms 3416 KB Correct
11 Correct 79 ms 3532 KB Correct
12 Correct 1 ms 356 KB Correct
13 Correct 0 ms 352 KB Correct
14 Correct 33 ms 2016 KB Correct
15 Correct 32 ms 2116 KB Correct
16 Correct 33 ms 2140 KB Correct
17 Correct 30 ms 1872 KB Correct
18 Correct 34 ms 2132 KB Correct
19 Correct 40 ms 2352 KB Correct
20 Correct 73 ms 3156 KB Correct
21 Correct 69 ms 3140 KB Correct
22 Correct 60 ms 2900 KB Correct
23 Incorrect 58 ms 2900 KB User solution is worse than jury's solution
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 28 ms 1372 KB Correct
4 Correct 1 ms 348 KB Correct
5 Correct 25 ms 1744 KB Correct
6 Correct 25 ms 1740 KB Correct
7 Correct 1 ms 344 KB Correct
8 Correct 0 ms 344 KB Correct
9 Correct 6 ms 672 KB Correct
10 Correct 0 ms 344 KB Correct
11 Correct 32 ms 1620 KB Correct
12 Correct 5 ms 600 KB Correct
13 Correct 64 ms 3440 KB Correct
14 Correct 70 ms 3408 KB Correct
15 Correct 0 ms 344 KB Correct
16 Correct 1 ms 348 KB Correct
17 Correct 56 ms 3460 KB Correct
18 Correct 56 ms 3412 KB Correct
19 Correct 62 ms 3408 KB Correct
20 Correct 33 ms 2132 KB Correct
21 Correct 38 ms 2140 KB Correct
22 Correct 58 ms 2388 KB Correct
23 Correct 57 ms 2664 KB Correct
24 Correct 52 ms 2896 KB Correct
25 Correct 40 ms 2384 KB Correct
26 Correct 1 ms 344 KB Correct
27 Correct 1 ms 348 KB Correct
28 Correct 1 ms 348 KB Correct
29 Correct 1 ms 348 KB Correct
30 Correct 0 ms 348 KB Correct
31 Correct 1 ms 348 KB Correct
32 Correct 1 ms 348 KB Correct
33 Correct 1 ms 348 KB Correct
34 Correct 0 ms 348 KB Correct
35 Correct 1 ms 348 KB Correct
36 Correct 1 ms 348 KB Correct
37 Correct 1 ms 348 KB Correct
38 Correct 1 ms 348 KB Correct
39 Correct 1 ms 348 KB Correct
40 Correct 0 ms 348 KB Correct
41 Correct 1 ms 348 KB Correct
42 Correct 1 ms 348 KB Correct
43 Correct 1 ms 348 KB Correct
44 Correct 32 ms 1840 KB Correct
45 Correct 76 ms 3308 KB Correct
46 Correct 82 ms 3536 KB Correct
47 Correct 79 ms 3408 KB Correct
48 Correct 77 ms 3376 KB Correct
49 Correct 79 ms 3352 KB Correct
50 Correct 95 ms 3416 KB Correct
51 Correct 83 ms 3416 KB Correct
52 Correct 79 ms 3416 KB Correct
53 Correct 79 ms 3532 KB Correct
54 Correct 1 ms 356 KB Correct
55 Correct 0 ms 352 KB Correct
56 Correct 33 ms 2016 KB Correct
57 Correct 32 ms 2116 KB Correct
58 Correct 33 ms 2140 KB Correct
59 Correct 30 ms 1872 KB Correct
60 Correct 34 ms 2132 KB Correct
61 Correct 40 ms 2352 KB Correct
62 Correct 73 ms 3156 KB Correct
63 Correct 69 ms 3140 KB Correct
64 Correct 60 ms 2900 KB Correct
65 Incorrect 58 ms 2900 KB User solution is worse than jury's solution
66 Halted 0 ms 0 KB -