Submission #1039596

# Submission time Handle Problem Language Result Execution time Memory
1039596 2024-07-31T05:11:30 Z 김은성(#10990) Sprinklers (CEOI24_sprinklers) C++17
17 / 100
2000 ms 856 KB
#include <bits/stdc++.h>
using namespace std;
int s[100009], f[100009];
bool ch[1009];
int main(){
    int n, m, i, j, k;
    scanf("%d %d", &n, &m);
    for(i=1; i<=n; i++)
        scanf("%d", &s[i]);
    for(i=1; i<=m; i++)
        scanf("%d", &f[i]);
    int lo = 0, hi = 1000000009, mid;
    while(lo < hi){
        mid = (lo+hi)/2;
        int pos = -1;
        for(i=0; i<(1<<n); i++){
            for(j=1; j<=m; j++)
                ch[j] = 0;
            for(j=0; j<n; j++){
                for(k=1; k<=m; k++){
                    if((i & (1<<j)) && f[k] >= s[j+1]-mid && f[k] <= s[j+1])
                        ch[k] = 1;
                    if(!(i&(1<<j)) && f[k] <= s[j+1]+mid && f[k] >= s[j+1])
                        ch[k] = 1;
                }
            }
            bool flag = 0;
            for(j=1; j<=m; j++){
                if(!ch[j])
                    flag = 1;
            }
            if(!flag){
                pos = i;
                break;
            }
        }
        if(pos == -1)
            lo = mid+1;
        else
            hi = mid;
    }
    mid = lo;
    int pos = -1;
    for(i=0; i<(1<<n); i++){
        for(j=1; j<=m; j++)
            ch[j] = 0;
        for(j=0; j<n; j++){
            for(k=1; k<=m; k++){
                if((i & (1<<j)) && f[k] >= s[j+1]-mid && f[k] <= s[j+1])
                    ch[k] = 1;
                if(!(i&(1<<j)) && f[k] <= s[j+1]+mid && f[k] >= s[j+1])
                    ch[k] = 1;
            }
        }
        bool flag = 0;
        for(j=1; j<=m; j++){
            if(!ch[j])
                flag = 1;
        }
        if(!flag){
            pos = i;
            break;
        }
    }
    if(pos == -1)
        printf("-1\n");
    else{
        printf("%d\n", mid);
        for(i=0; i<n; i++)
            printf("%c", (pos & (1<<i)) ? 'L' : 'R');
        printf("\n");
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:9:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |         scanf("%d", &s[i]);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:11:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |         scanf("%d", &f[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 0 ms 344 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Incorrect 19 ms 856 KB User solution is worse than jury's solution
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Execution timed out 2049 ms 604 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 0 ms 344 KB Correct
3 Correct 55 ms 600 KB Correct
4 Correct 5 ms 344 KB Correct
5 Correct 161 ms 348 KB Correct
6 Correct 114 ms 344 KB Correct
7 Correct 2 ms 344 KB Correct
8 Correct 122 ms 440 KB Correct
9 Correct 134 ms 344 KB Correct
10 Correct 238 ms 436 KB Correct
11 Correct 19 ms 344 KB Correct
12 Correct 177 ms 348 KB Correct
13 Correct 119 ms 348 KB Correct
14 Correct 12 ms 344 KB Correct
15 Correct 33 ms 456 KB Correct
16 Correct 46 ms 348 KB Correct
17 Correct 72 ms 348 KB Correct
18 Correct 9 ms 348 KB Correct
19 Correct 1 ms 600 KB Correct
20 Correct 1 ms 348 KB Correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Execution timed out 2032 ms 856 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Correct
2 Correct 0 ms 344 KB Correct
3 Incorrect 19 ms 856 KB User solution is worse than jury's solution
4 Halted 0 ms 0 KB -