답안 #894355

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894355 2023-12-28T07:09:03 Z vjudge1 Cipele (COCI18_cipele) C++17
45 / 90
39 ms 5868 KB
#include <bits/stdc++.h>
#define ll long long
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define ull unsigned long long
#define ld long double
#define lv v+v
#define rv v+v+1
#define files freopen("expert.in", "r", stdin), freopen("expert.out", "w", stdout)
using namespace std;
const ll mod = 1e9 + 7;
const ll N = 1e5 + 10;
const ll P = 337ll;
const ld EPS = 1e-9;
const ll block = 450;
ll n,m,a[N],b[N];
queue <ll> q;
bool check(ll t) {
    for(ll i = 1; i<=n; i++) {
        q.push(a[i]);
    }
    ll idx = 1, cnt= 0;
    while(!q.empty() && idx <= m) {
        ll cur = q.front();
       // cout<<cur<<" "<<b[idx]<<"\n";
        if(abs(cur - b[idx]) <= t) {

            cnt++;
            idx++;
        }
        else if(cur >= b[idx]) {
            idx++;
            continue;
        }
        q.pop();
    }
   // cout<<t<<"\n\n\n";
    return cnt>=min(n,m);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin>>n>>m;
for(ll i = 1; i<=n; ++i) {
    cin>>a[i];
}
for(ll i = 1; i<=m; i++) {
    cin>>b[i];
}
sort(a+1, a+1+n);
sort(b+1, b+1+m);
ll l = -1, r = 1e9;
while(l + 1 < r) {
    ll mid = l + r >> 1LL;
    if(check(mid)) {
        r = mid;
    }
    else {
        l = mid;
    }
}
cout<<r;
return 0;
}
// equal, min, max, 1, random, build
/*
5 5
7 6 1 2 10
9 11 6 3 12
4 3
2 39 41 45
39 42 46
*/

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:58:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   58 |     ll mid = l + r >> 1LL;
      |              ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2648 KB Output is correct
2 Correct 35 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 2140 KB Output is correct
2 Incorrect 23 ms 1880 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 5868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 2120 KB Output is correct
2 Incorrect 34 ms 2296 KB Output isn't correct
3 Halted 0 ms 0 KB -