Submission #150867

# Submission time Handle Problem Language Result Execution time Memory
150867 2019-09-01T09:23:54 Z PedroBigMan Cipele (COCI18_cipele) C++14
0 / 90
1000 ms 6128 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF ((ll) pow(2,63) -1)
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
vector<ll> a,b,ind,ind1,ind2; ll N,M;

ll Check(vector<ll> sub)
{
    ll ans=0;
    REP(i,0,N)
    {
        ans=max(ans,abs(a[i]-b[sub[i]]));
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>N>>M; if(N<=M) {In(a,N); In(b,M);} else {In(b,N); In(a,M);}
    ll x=N; ll y=M; N=min(x,y); M=max(x,y);
    sort(a.begin(),a.end()); sort(b.begin(),b.end());
    ll ne;
    REP(i,0,N)
    {
        ne = (ll) (lower_bound(b.begin(),b.end(),a[i]) - b.begin());
        if(ne==0)
        {
            ind.pb(0);
        }
        else if(ne==M)
        {
            ind.pb(M-1);
        }
        else
        {
            if(abs(a[i]-b[ne])>abs(a[i]-b[ne-1])) {ind.pb(ne-1);}
            else {ind.pb(ne);}
        }
    }
    ll ans;
    REP(i,0,ind.size()-1)
    {
        if(ind[i]!=ind[i+1]) {continue;}
        ind1.clear(); ind2.clear(); ind1=ind; ind2=ind;
        ll cur=i;
        while(ind1[cur]==ind1[cur+1])
        {
            ind1[cur]--;
            cur--;
        }
        cur=i+1;
        while(ind2[cur]==ind2[cur-1])
        {
            ind2[cur]++;
            cur++;
        }
        if(Check(ind1)>Check(ind2)) {ind=ind2;}
        else {ind=ind1;}
    }
    cout<<Check(ind)<<endl;
    return 0;
}

Compilation message

cipele.cpp: In function 'void Out(std::vector<long long int>)':
cipele.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
cipele.cpp:19:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
cipele.cpp:19:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
cipele.cpp: In function 'int main()':
cipele.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
cipele.cpp:58:9:
     REP(i,0,ind.size()-1)
         ~~~~~~~~~~~~~~~~         
cipele.cpp:58:5: note: in expansion of macro 'REP'
     REP(i,0,ind.size()-1)
     ^~~
cipele.cpp:57:8: warning: unused variable 'ans' [-Wunused-variable]
     ll ans;
        ^~~
# Verdict Execution time Memory Grader output
1 Correct 41 ms 3628 KB Output is correct
2 Execution timed out 1070 ms 6076 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 6128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 153 ms 708 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 380 KB Output is correct
2 Incorrect 153 ms 632 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1038 ms 4476 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1046 ms 5284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 4532 KB Time limit exceeded
2 Halted 0 ms 0 KB -