Submission #1091135

# Submission time Handle Problem Language Result Execution time Memory
1091135 2024-09-19T22:41:07 Z Pajaraja Sprinklers (CEOI24_sprinklers) C++17
9 / 100
71 ms 1884 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[d+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(s[d+1]>=f[i]) d++;
        if(d>=0 && s[d]!=f[i]) bt[i]=true;
    }
    int ans=binarna(1,1000000000);
    if(!check(ans)) {
        cout<<-1;
        return 0;
    }
    cout<<ans<<endl<<res<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Correct
2 Correct 21 ms 1632 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 24 ms 1876 KB Correct
5 Correct 25 ms 1884 KB Correct
6 Correct 1 ms 348 KB Correct
7 Correct 0 ms 444 KB Correct
8 Correct 5 ms 560 KB Correct
9 Correct 1 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 25 ms 852 KB Correct
3 Correct 5 ms 348 KB Correct
4 Correct 60 ms 1416 KB Correct
5 Correct 71 ms 1360 KB Correct
6 Correct 1 ms 344 KB Correct
7 Correct 0 ms 344 KB Correct
8 Correct 51 ms 1380 KB Correct
9 Correct 52 ms 1484 KB Correct
10 Correct 63 ms 1552 KB Correct
11 Correct 30 ms 1116 KB Correct
12 Correct 36 ms 1108 KB Correct
13 Correct 40 ms 1372 KB Correct
14 Correct 44 ms 1400 KB Correct
15 Correct 62 ms 1280 KB Correct
16 Correct 38 ms 1444 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Incorrect 1 ms 344 KB User solution is worse than jury's solution
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Incorrect 31 ms 804 KB User solution is incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 1 ms 344 KB Correct
3 Correct 21 ms 1632 KB Correct
4 Correct 1 ms 344 KB Correct
5 Correct 24 ms 1876 KB Correct
6 Correct 25 ms 1884 KB Correct
7 Correct 1 ms 348 KB Correct
8 Correct 0 ms 444 KB Correct
9 Correct 5 ms 560 KB Correct
10 Correct 1 ms 348 KB Correct
11 Correct 25 ms 852 KB Correct
12 Correct 5 ms 348 KB Correct
13 Correct 60 ms 1416 KB Correct
14 Correct 71 ms 1360 KB Correct
15 Correct 1 ms 344 KB Correct
16 Correct 0 ms 344 KB Correct
17 Correct 51 ms 1380 KB Correct
18 Correct 52 ms 1484 KB Correct
19 Correct 63 ms 1552 KB Correct
20 Correct 30 ms 1116 KB Correct
21 Correct 36 ms 1108 KB Correct
22 Correct 40 ms 1372 KB Correct
23 Correct 44 ms 1400 KB Correct
24 Correct 62 ms 1280 KB Correct
25 Correct 38 ms 1444 KB Correct
26 Incorrect 1 ms 344 KB User solution is worse than jury's solution
27 Halted 0 ms 0 KB -