답안 #1039549

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039549 2024-07-31T04:19:14 Z 변재우(#10994) Sprinklers (CEOI24_sprinklers) C++17
3 / 100
14 ms 2392 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int Nmax=100010;
int N, M, ans=-1, A[Nmax], B[Nmax];

bool chk(int k, bool op) {
    string s;
    for(int i=1, j=1; i<=M; i++) {
        bool flag=false;
        while(j<=N && !flag) {
            flag|=(abs(B[i]-A[j])<=k);
            if(A[j]<=B[i]) {
                s+='R';
                while(B[i]-A[j]<=k) i++; i--;
            }
            else {
                s+='L';
                while(A[j]-B[i]>=0) i++; i--;
            }
            j++;
        }
        if(!flag) return false;
    }
    while(s.size()<N) s+='L';
    if(op) cout<<s;
    return true;
}

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>M;
    for(int i=1; i<=N; i++) cin>>A[i];
    for(int i=1; i<=M; i++) cin>>B[i];
    for(int s=0, e=1e9; s<=e; ) {
        int mid=(s+e)/2;
        if(chk(mid, false)) ans=mid, e=mid-1;
        else s=mid+1;
    }
    cout<<ans<<"\n";
    chk(ans, true);
    return 0;
}

Compilation message

Main.cpp: In function 'bool chk(long long int, bool)':
Main.cpp:16:17: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   16 |                 while(B[i]-A[j]<=k) i++; i--;
      |                 ^~~~~
Main.cpp:16:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   16 |                 while(B[i]-A[j]<=k) i++; i--;
      |                                          ^
Main.cpp:20:17: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   20 |                 while(A[j]-B[i]>=0) i++; i--;
      |                 ^~~~~
Main.cpp:20:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   20 |                 while(A[j]-B[i]>=0) i++; i--;
      |                                          ^
Main.cpp:26:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   26 |     while(s.size()<N) s+='L';
      |           ~~~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Correct
2 Correct 8 ms 1884 KB Correct
3 Correct 4 ms 348 KB Correct
4 Correct 11 ms 2136 KB Correct
5 Correct 8 ms 2208 KB Correct
6 Correct 2 ms 348 KB Correct
7 Correct 3 ms 348 KB Correct
8 Correct 2 ms 604 KB Correct
9 Correct 4 ms 348 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Correct
2 Correct 11 ms 2140 KB Correct
3 Incorrect 6 ms 604 KB User solution is incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
3 Incorrect 3 ms 344 KB User solution is worse than jury's solution
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Correct
2 Incorrect 14 ms 2392 KB User solution is incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 348 KB Correct
2 Correct 0 ms 348 KB Correct
3 Correct 8 ms 1884 KB Correct
4 Correct 4 ms 348 KB Correct
5 Correct 11 ms 2136 KB Correct
6 Correct 8 ms 2208 KB Correct
7 Correct 2 ms 348 KB Correct
8 Correct 3 ms 348 KB Correct
9 Correct 2 ms 604 KB Correct
10 Correct 4 ms 348 KB Correct
11 Correct 11 ms 2140 KB Correct
12 Incorrect 6 ms 604 KB User solution is incorrect
13 Halted 0 ms 0 KB -