답안 #240204

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
240204 2020-06-18T18:21:24 Z hzhuarry Cipele (COCI18_cipele) C++17
72 / 90
59 ms 3068 KB
#include <bits/stdc++.h>
#include <fstream>

using namespace std;

#define endl "\n"
#define pf push_front
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define f first
#define s second
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PI 3.14159265358979323846264338327950L
#define lb lower_bound
#define ub upper_bound


typedef long long ll;
typedef long double ld;
typedef string str;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<ld> vd;
typedef vector<str> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pld> vpd;

const int MOD = 1000000007;
const int dx[4]= {-1,1,0,0}, dy[4]= {0,0,-1,1}; //flood

int N,M;
vi l,r;

bool ok(int ugly)
{
    int cnt=0,j=0;
    for(int i=0;i<N&&j<M;++i)
    {
        int curr=l[i];
        while(j<M&&abs(r[j]-curr)>ugly)++j;
        cnt++;
        ++j;
    }
    return cnt>=N;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //ifstream cin (".in");
    //ofstream cout (".out");
    
    cin>>N>>M;
    for(int i=0;i<N;++i){
        int a;
        cin>>a;
        l.pb(a);
    }
    for(int i=0;i<M;++i)
    {
        int b;
        cin>>b;
        r.pb(b);
    }
    if(N>M)
    {
        swap(l,r);
        swap(N, M);
    }
    SORT(l);
    SORT(r);
    int lo=0,hi=1e9;
    while(lo<hi)
    {
        int mid=(lo+hi)/2;
        if(ok(mid)){
            hi=mid;
        }
        else{
            lo=mid+1;
        }
    }
    cout<<lo<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 1532 KB Output is correct
2 Correct 53 ms 2940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 1532 KB Output is correct
2 Correct 58 ms 1532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Incorrect 7 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Output is correct
2 Incorrect 7 ms 640 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 512 KB Output is correct
2 Correct 7 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 2788 KB Output is correct
2 Correct 34 ms 1920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 2976 KB Output is correct
2 Correct 27 ms 2300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 2716 KB Output is correct
2 Correct 50 ms 3068 KB Output is correct