Submission #1070063

# Submission time Handle Problem Language Result Execution time Memory
1070063 2024-08-22T11:25:24 Z vjudge1 Sprinklers (CEOI24_sprinklers) C++17
26 / 100
92 ms 2136 KB

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    if(n > 10){
    long long int s[n];
    long long int f[m];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    long long int ans = -1;
    
    for(int i = 0; i < m; i++){
        cin >> f[i];
    
        int ans1 = -1;
        int l = 0;
        int r = n - 1;
        while(l <= r){
            int mid = (l + r) / 2;
            if(s[mid] <= f[i]){
                ans1 = max(ans1, mid);
                    l = mid + 1;
                
            }else{
                r = mid - 1;
            }
        }
        long long int mini = 1e18;
        if(ans1 != -1){
            mini = f[i] - s[ans1];
        }
        int ans2 = n + 1;
         l = 0;
         r = n - 1;
         while(l <= r){
              int mid = (l + r) / 2;
            if(s[mid] >= f[i]){
                ans2 = min(ans2, mid);
                    r = mid - 1;
                
            }else{
                l = mid + 1;
            }
         }
         if(ans2 != (n + 1)){
             mini = min(mini, s[ans2] - f[i]);
         }
        ans = max(ans, mini);
        
    }
    cout << ans << endl;
    for(int i = 0; i < n; i++){
        if(i % 3 == 0 or i % 3 == 2){
            cout << "R";
        }else{
            cout << "L";
        }
    }
    }else{
        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";
            }
        }
    }
    }
    
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 29 ms 860 KB Correct
3 Correct 0 ms 348 KB Correct
4 Correct 24 ms 1216 KB Correct
5 Correct 26 ms 1116 KB Correct
6 Correct 1 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 6 ms 584 KB Correct
9 Correct 0 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct
2 Correct 28 ms 1116 KB Correct
3 Correct 4 ms 348 KB Correct
4 Correct 58 ms 1968 KB Correct
5 Correct 92 ms 2136 KB Correct
6 Correct 0 ms 348 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 56 ms 1984 KB Correct
9 Correct 67 ms 1880 KB Correct
10 Correct 55 ms 1972 KB Correct
11 Correct 29 ms 1112 KB Correct
12 Correct 38 ms 1416 KB Correct
13 Correct 38 ms 1628 KB Correct
14 Correct 40 ms 1628 KB Correct
15 Correct 49 ms 1724 KB Correct
16 Correct 39 ms 1624 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 6 ms 348 KB Correct
4 Correct 1 ms 344 KB Correct
5 Correct 11 ms 348 KB Correct
6 Correct 23 ms 436 KB Correct
7 Correct 0 ms 348 KB Correct
8 Correct 24 ms 348 KB Correct
9 Correct 11 ms 344 KB Correct
10 Correct 11 ms 348 KB Correct
11 Correct 2 ms 344 KB Correct
12 Correct 11 ms 348 KB Correct
13 Correct 24 ms 428 KB Correct
14 Correct 1 ms 348 KB Correct
15 Correct 16 ms 348 KB Correct
16 Correct 8 ms 348 KB Correct
17 Correct 7 ms 348 KB Correct
18 Correct 7 ms 344 KB Correct
19 Correct 1 ms 348 KB Correct
20 Correct 1 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct
2 Incorrect 30 ms 1288 KB User solution is incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 29 ms 860 KB Correct
4 Correct 0 ms 348 KB Correct
5 Correct 24 ms 1216 KB Correct
6 Correct 26 ms 1116 KB Correct
7 Correct 1 ms 348 KB Correct
8 Correct 0 ms 348 KB Correct
9 Correct 6 ms 584 KB Correct
10 Correct 0 ms 348 KB Correct
11 Correct 28 ms 1116 KB Correct
12 Correct 4 ms 348 KB Correct
13 Correct 58 ms 1968 KB Correct
14 Correct 92 ms 2136 KB Correct
15 Correct 0 ms 348 KB Correct
16 Correct 0 ms 348 KB Correct
17 Correct 56 ms 1984 KB Correct
18 Correct 67 ms 1880 KB Correct
19 Correct 55 ms 1972 KB Correct
20 Correct 29 ms 1112 KB Correct
21 Correct 38 ms 1416 KB Correct
22 Correct 38 ms 1628 KB Correct
23 Correct 40 ms 1628 KB Correct
24 Correct 49 ms 1724 KB Correct
25 Correct 39 ms 1624 KB Correct
26 Correct 6 ms 348 KB Correct
27 Correct 1 ms 344 KB Correct
28 Correct 11 ms 348 KB Correct
29 Correct 23 ms 436 KB Correct
30 Correct 0 ms 348 KB Correct
31 Correct 24 ms 348 KB Correct
32 Correct 11 ms 344 KB Correct
33 Correct 11 ms 348 KB Correct
34 Correct 2 ms 344 KB Correct
35 Correct 11 ms 348 KB Correct
36 Correct 24 ms 428 KB Correct
37 Correct 1 ms 348 KB Correct
38 Correct 16 ms 348 KB Correct
39 Correct 8 ms 348 KB Correct
40 Correct 7 ms 348 KB Correct
41 Correct 7 ms 344 KB Correct
42 Correct 1 ms 348 KB Correct
43 Correct 1 ms 348 KB Correct
44 Incorrect 30 ms 1288 KB User solution is incorrect
45 Halted 0 ms 0 KB -