답안 #472525

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472525 2021-09-13T16:59:49 Z Beboo44 Cipele (COCI18_cipele) C++17
27 / 90
200 ms 262148 KB
#include <bits/stdc++.h>
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair<ll , int> > vpli;
typedef set<char> st;
typedef stack<int> s;
typedef deque<int> dq;
typedef queue<int> q;
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0)
int minugly (vector<ll> x, vector<ll> y, int i,int j){
    if(j-i+1==y.size()){
            ll ans =0;
        for(int f=0; f<x.size();++f){
            ans = max(ans,abs(x[f]-y[f]));
        }
        return ans;
    }
    else{

    if(abs(x[i]-y[0])>abs(x[j]-y[y.size()-1])){
        x.erase(x.begin()+i);
       return  minugly(x,y,i,x.size()-1);
    }
    else if (abs(x[j]-y[y.size()-1])>abs(x[i]-y[0])){
        x.erase(x.begin()+j);
       return minugly(x,y,i,x.size()-1);
    }
    else{
        int choice1 = minugly(x,y,i+1,j);
        int choice2 = minugly(x,y,i,j-1);
        return min(choice1,choice2);
    }

}
}



int main()
{
 ll n,m;
 cin>>n>>m;
 vector<ll>leftt(n);
 vector<ll>rightt(m);
 for(int i=0; i<n; ++i){
    cin>>leftt[i];
 }
for(int i=0; i<m; ++i){
    cin>>rightt[i];
 }
 sort(leftt.begin(),leftt.end());
 sort(rightt.begin(),rightt.end());
 ll ans=0;
 if(leftt.size()>rightt.size()){
    ans = minugly(leftt,rightt,0,n-1);
 }
 else if (leftt.size()<rightt.size()){
    ans = minugly(rightt,leftt,0,m-1);
 }
 else{
    for(int i=0; i<n; ++i){
        ans=max(ans,abs(leftt[i]-rightt[i]));
    }
 }
cout<<ans<<endl;


    return 0;
}

Compilation message

cipele.cpp: In function 'int minugly(std::vector<long long int>, std::vector<long long int>, int, int)':
cipele.cpp:14:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     if(j-i+1==y.size()){
      |        ~~~~~^~~~~~~~~~
cipele.cpp:16:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(int f=0; f<x.size();++f){
      |                      ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 93 ms 1868 KB Output is correct
2 Correct 96 ms 1868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 97 ms 1740 KB Output is correct
2 Correct 96 ms 1868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 6 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 103076 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 91716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 91692 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 36744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 200 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 195 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 179 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -