답안 #1046052

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046052 2024-08-06T09:27:30 Z gagik_2007 Sprinklers (CEOI24_sprinklers) C++17
23 / 100
13 ms 1164 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define ff first
#define ss second

ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=100007;
ll n,m,k;
int f[N],s[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("Finput.txt","r",stdin);
    // freopen("Foutput.txt","w",stdout);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    for(int i=0;i<m;i++){
        cin>>f[i];
    }
    if(n<=10&&m<=1000){
        int ans=MOD;
        int ansmsk=0;
        for(int msk=0;msk<(1<<n);msk++){
            int curmax=0;
            for(int j=0;j<m;j++){
                int cur=MOD;
                for(int i=0;i<n;i++){
                    if(
                        (
                            (msk&(1<<i)) && s[i]<=f[j]
                        )||(
                            (!(msk&(1<<i))) && s[i]>=f[j]
                        )
                    ){
                        cur=min(cur,abs(s[i]-f[j]));
                    }
                }
                curmax=max(curmax, cur);
            }
            if(ans>curmax){
                ans=curmax;
                ansmsk=msk;
            }
        }
        if(ans==MOD){
            cout<<-1<<endl;
            return 0;
        }
        cout<<ans<<endl;
        for(int i=0;i<n;i++){
            if(ansmsk&(1<<i)){
                cout<<"R";
            }
            else{
                cout<<"L";
            }
        }
        cout<<endl;
    }
    else{
        int ans=0;
        int l=0;
        for(int j=0;j<m;j++){
            while(l<n-1&&s[l+1]<f[j]){
                l++;
            }
            int dist=abs(f[j]-s[l]);
            if(l<n-1){
                dist=min(dist,abs(f[j]-s[l+1]));
            }
            ans=max(ans,dist);
        }
        cout<<ans<<endl;
        for(int i=0;i<n;i+=3){
            cout<<"LLR";
        }
        cout<<endl;
    }
}
# 결과 실행 시간 메모리 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 Incorrect 5 ms 756 KB Incorrect string length
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 5 ms 860 KB Correct
3 Correct 1 ms 348 KB Correct
4 Correct 13 ms 1116 KB Correct
5 Correct 11 ms 1164 KB Correct
6 Correct 0 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 11 ms 1088 KB Correct
9 Correct 11 ms 1112 KB Correct
10 Correct 12 ms 1116 KB Correct
11 Correct 6 ms 860 KB Correct
12 Correct 7 ms 908 KB Correct
13 Correct 8 ms 1116 KB Correct
14 Correct 9 ms 1112 KB Correct
15 Correct 9 ms 1112 KB Correct
16 Correct 8 ms 1116 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 5 ms 348 KB Correct
4 Correct 0 ms 348 KB Correct
5 Correct 9 ms 348 KB Correct
6 Correct 9 ms 472 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 8 ms 348 KB Correct
9 Correct 9 ms 348 KB Correct
10 Correct 8 ms 348 KB Correct
11 Correct 2 ms 348 KB Correct
12 Correct 8 ms 472 KB Correct
13 Correct 8 ms 344 KB Correct
14 Correct 1 ms 480 KB Correct
15 Correct 6 ms 348 KB Correct
16 Correct 6 ms 348 KB Correct
17 Correct 6 ms 348 KB Correct
18 Correct 6 ms 348 KB Correct
19 Correct 0 ms 348 KB Correct
20 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Incorrect 6 ms 856 KB Incorrect string length
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
3 Incorrect 5 ms 756 KB Incorrect string length
4 Halted 0 ms 0 KB -