답안 #1070023

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1070023 2024-08-22T11:04:22 Z vjudge1 Sprinklers (CEOI24_sprinklers) C++17
20 / 100
2000 ms 1276 KB

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    long long int s[n];
    long long int f[m];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    for(int i = 0; i < m; i++){
        cin >> f[i];
    }
    long long int ans = 1e18;  
    long long int INF = 1e18;
    int br1[n];
    
    for(int k = 0; k < (1 << n); k++){
        int br[n];
        for(int j = 0; j < n; j++){
            br[j] = 0;
        }
        int k1 = k;
        int brojac = 0;
        while(k1 > 0){
            if(k1 % 2 == 1){
                br[brojac]++;
            }
            brojac++;
            k1 = k1 / 2;
        }
        long long int res = 0;
     
        for(int i = 0; i < m; i++){
            long long int mini = 1e18;
            for(int j = 0; j < n; j++){
                if(br[j] == 0){
                    if(s[j] <= f[i]){
                        mini = min(mini, f[i] - s[j]);
                    }
                }else{
                    if(s[j] >= f[i]){
                        mini = min(mini, s[j] - f[i]);
                    }
                }
            }
            res = max(res, mini);
        }
        if(res < ans){ 
            ans = min(ans, res);
            for(int j = 0; j < n; j++){
                br1[j] = br[j];
            }
        }
    
        
    }
    if(ans == INF){
        cout << -1;
    }else{
        cout << ans <<endl;
        for(int i = 0; i < n; i++){
            if(br1[i] == 0){
                cout << "R";
            }else{
                cout << "L";
            }
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Correct
2 Correct 1 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Correct
2 Correct 23 ms 860 KB Correct
3 Correct 1 ms 348 KB Correct
4 Correct 46 ms 1116 KB Correct
5 Correct 27 ms 1116 KB Correct
6 Correct 0 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 5 ms 348 KB Correct
9 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Correct
2 Execution timed out 2092 ms 1116 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Correct
2 Correct 1 ms 348 KB Correct
3 Correct 6 ms 436 KB Correct
4 Correct 1 ms 348 KB Correct
5 Correct 16 ms 348 KB Correct
6 Correct 17 ms 432 KB Correct
7 Correct 1 ms 348 KB Correct
8 Correct 15 ms 432 KB Correct
9 Correct 15 ms 348 KB Correct
10 Correct 11 ms 348 KB Correct
11 Correct 2 ms 348 KB Correct
12 Correct 13 ms 348 KB Correct
13 Correct 11 ms 436 KB Correct
14 Correct 1 ms 348 KB Correct
15 Correct 7 ms 432 KB Correct
16 Correct 9 ms 436 KB Correct
17 Correct 8 ms 348 KB Correct
18 Correct 13 ms 604 KB Correct
19 Correct 1 ms 348 KB Correct
20 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Correct
2 Execution timed out 2066 ms 1276 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Correct
2 Correct 1 ms 348 KB Correct
3 Correct 23 ms 860 KB Correct
4 Correct 1 ms 348 KB Correct
5 Correct 46 ms 1116 KB Correct
6 Correct 27 ms 1116 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 0 ms 348 KB Correct
9 Correct 5 ms 348 KB Correct
10 Correct 0 ms 348 KB Correct
11 Execution timed out 2092 ms 1116 KB Time limit exceeded
12 Halted 0 ms 0 KB -