답안 #1046054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046054 2024-08-06T09:28:16 Z gagik_2007 Sprinklers (CEOI24_sprinklers) C++17
26 / 100
22 ms 1296 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)||n==1){
        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 Correct 5 ms 600 KB Correct
3 Correct 0 ms 348 KB Correct
4 Correct 6 ms 680 KB Correct
5 Correct 6 ms 648 KB Correct
6 Correct 0 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 1 ms 344 KB Correct
9 Correct 0 ms 344 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 11 ms 860 KB Correct
3 Correct 1 ms 344 KB Correct
4 Correct 22 ms 1112 KB Correct
5 Correct 22 ms 1120 KB Correct
6 Correct 0 ms 344 KB Correct
7 Correct 1 ms 348 KB Correct
8 Correct 11 ms 1296 KB Correct
9 Correct 11 ms 1132 KB Correct
10 Correct 12 ms 1116 KB Correct
11 Correct 6 ms 860 KB Correct
12 Correct 12 ms 784 KB Correct
13 Correct 8 ms 1116 KB Correct
14 Correct 11 ms 1116 KB Correct
15 Correct 10 ms 984 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 1 ms 348 KB Correct
5 Correct 10 ms 348 KB Correct
6 Correct 8 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 10 ms 348 KB Correct
9 Correct 10 ms 472 KB Correct
10 Correct 10 ms 348 KB Correct
11 Correct 1 ms 348 KB Correct
12 Correct 9 ms 472 KB Correct
13 Correct 9 ms 348 KB Correct
14 Correct 2 ms 344 KB Correct
15 Correct 6 ms 348 KB Correct
16 Correct 6 ms 348 KB Correct
17 Correct 8 ms 348 KB Correct
18 Correct 8 ms 464 KB Correct
19 Correct 1 ms 508 KB Correct
20 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Incorrect 11 ms 860 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 Correct 5 ms 600 KB Correct
4 Correct 0 ms 348 KB Correct
5 Correct 6 ms 680 KB Correct
6 Correct 6 ms 648 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 0 ms 348 KB Correct
9 Correct 1 ms 344 KB Correct
10 Correct 0 ms 344 KB Correct
11 Correct 11 ms 860 KB Correct
12 Correct 1 ms 344 KB Correct
13 Correct 22 ms 1112 KB Correct
14 Correct 22 ms 1120 KB Correct
15 Correct 0 ms 344 KB Correct
16 Correct 1 ms 348 KB Correct
17 Correct 11 ms 1296 KB Correct
18 Correct 11 ms 1132 KB Correct
19 Correct 12 ms 1116 KB Correct
20 Correct 6 ms 860 KB Correct
21 Correct 12 ms 784 KB Correct
22 Correct 8 ms 1116 KB Correct
23 Correct 11 ms 1116 KB Correct
24 Correct 10 ms 984 KB Correct
25 Correct 8 ms 1116 KB Correct
26 Correct 5 ms 348 KB Correct
27 Correct 1 ms 348 KB Correct
28 Correct 10 ms 348 KB Correct
29 Correct 8 ms 348 KB Correct
30 Correct 0 ms 348 KB Correct
31 Correct 10 ms 348 KB Correct
32 Correct 10 ms 472 KB Correct
33 Correct 10 ms 348 KB Correct
34 Correct 1 ms 348 KB Correct
35 Correct 9 ms 472 KB Correct
36 Correct 9 ms 348 KB Correct
37 Correct 2 ms 344 KB Correct
38 Correct 6 ms 348 KB Correct
39 Correct 6 ms 348 KB Correct
40 Correct 8 ms 348 KB Correct
41 Correct 8 ms 464 KB Correct
42 Correct 1 ms 508 KB Correct
43 Correct 0 ms 348 KB Correct
44 Incorrect 11 ms 860 KB Incorrect string length
45 Halted 0 ms 0 KB -