답안 #1044371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1044371 2024-08-05T09:05:30 Z imarn Sprinklers (CEOI24_sprinklers) C++14
9 / 100
33 ms 3764 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define ub(a,b) upper_bound(a.begin(),a.end(),b)-a.begin();
#define lb(a,b) lower_bound(a.begin(),a.end(),b)-a.begin();
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define sz(x) x.size()
#define T pair<double,string>
using namespace std;
const int mxn=2e5+5;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,m;cin>>n>>m;
    ll s[n+1],f[m+1];
    for(int i=1;i<=n;i++)cin>>s[i];
    for(int i=1;i<=m;i++)cin>>f[i];
    ll l=0,r=1e12+1;
    int lr[n+1]={0};
    while(l<r){
        ll k=(l+r)>>1;
        int idx=1;memset(lr,0,sizeof lr);
        for(int i=1;i<=n;i++){
            while(idx<=m&&s[i]-k<=f[idx]&&f[idx]<s[i])idx++,lr[i]=1;
            while(f[idx]==s[i])idx++;
            while(idx<=m&&s[i]<=f[idx]&&f[idx]<=s[i]+k&&lr[i]!=1)idx++,lr[i]=2;
        }if(idx!=m+1)l=k+1;
        else r=k;
    }if(l==1e12+1){cout<<-1;return 0;}
    memset(lr,0,sizeof lr);int idx=1;
    for(int i=1;i<=n;i++){
        while(idx<=m&&s[i]-l<=f[idx]&&f[idx]<s[i])idx++,lr[i]=1;
        while(idx<=m&&s[i]<=f[idx]&&f[idx]<=s[i]+l&&lr[i]!=1)idx++,lr[i]=2;
        if(idx==m+1&&!lr[i])lr[i]=2;
    }cout<<l<<'\n';
    for(int i=1;i<=n;i++)cout<<(lr[i]==1?"L":"R");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 13 ms 1624 KB Correct
3 Correct 0 ms 344 KB Correct
4 Correct 7 ms 2000 KB Correct
5 Correct 14 ms 2140 KB Correct
6 Correct 1 ms 344 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 3 ms 604 KB Correct
9 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 15 ms 1880 KB Correct
3 Correct 5 ms 612 KB Correct
4 Correct 33 ms 3764 KB Correct
5 Correct 29 ms 3672 KB Correct
6 Correct 0 ms 448 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 21 ms 3664 KB Correct
9 Correct 20 ms 3676 KB Correct
10 Correct 25 ms 3744 KB Correct
11 Correct 31 ms 2384 KB Correct
12 Correct 15 ms 2396 KB Correct
13 Correct 28 ms 2840 KB Correct
14 Correct 24 ms 3164 KB Correct
15 Correct 24 ms 3156 KB Correct
16 Correct 20 ms 2908 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
3 Incorrect 1 ms 348 KB User solution is incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Incorrect 12 ms 1884 KB User solution is incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 13 ms 1624 KB Correct
4 Correct 0 ms 344 KB Correct
5 Correct 7 ms 2000 KB Correct
6 Correct 14 ms 2140 KB Correct
7 Correct 1 ms 344 KB Correct
8 Correct 0 ms 348 KB Correct
9 Correct 3 ms 604 KB Correct
10 Correct 0 ms 348 KB Correct
11 Correct 15 ms 1880 KB Correct
12 Correct 5 ms 612 KB Correct
13 Correct 33 ms 3764 KB Correct
14 Correct 29 ms 3672 KB Correct
15 Correct 0 ms 448 KB Correct
16 Correct 0 ms 348 KB Correct
17 Correct 21 ms 3664 KB Correct
18 Correct 20 ms 3676 KB Correct
19 Correct 25 ms 3744 KB Correct
20 Correct 31 ms 2384 KB Correct
21 Correct 15 ms 2396 KB Correct
22 Correct 28 ms 2840 KB Correct
23 Correct 24 ms 3164 KB Correct
24 Correct 24 ms 3156 KB Correct
25 Correct 20 ms 2908 KB Correct
26 Incorrect 1 ms 348 KB User solution is incorrect
27 Halted 0 ms 0 KB -