답안 #472229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472229 2021-09-13T09:54:43 Z MamdouhN Cipele (COCI18_cipele) C++14
18 / 90
1000 ms 3392 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

vector<int>R,L,nR;

main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        L.push_back(x);
    }
    for(int i=0;i<m;i++)
    {
        int x;
        cin>>x;
        R.push_back(x);
    }

    if(n>m)
    {
        swap(m,n);
        swap(L,R);
    }
    for(int i=0;i<R.size();i++)nR.push_back(R[i]*-1);
    sort(L.begin(),L.end());
    sort(R.begin(),R.end());
    sort(nR.begin(),nR.end());

    int ans = 0;
    for(int i=0;i<n;i++)
    {
        int idx1 = lower_bound(R.begin(),R.end(),L[i])-R.begin();
        int idx2 = lower_bound(nR.begin(),nR.end(),L[i]*-1)-nR.begin();
        int idx;
        if(idx1==R.size())idx1--;
        if(idx2==nR.size())idx2--;
        //cout<<idx1<<" "<<idx2<<endl;
        if( abs((L[i]*-1) - nR[idx2])  <  abs((L[i]) - R[idx1]) )
        {
            //cout<<"HELLO "<<R.size()<<" "<<idx2<<endl;
            idx = R.size()-idx2-1;
        }
        else idx = idx1;
        //cout<<idx<<endl;
        int x = L[i]- abs(L[i]-R[i]);
        //cout<<L[i]<<" "<<R[idx]<<" "<<idx<<endl;
        ans=max(ans,abs(L[i]-R[idx]));
        //cout<<ans<<endl;
        R.erase(R.begin()+idx);
        nR.erase(nR.begin()+(nR.size()-idx-1));
    }
    cout<<ans<<endl;
}

Compilation message

cipele.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
cipele.cpp: In function 'int main()':
cipele.cpp:30:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for(int i=0;i<R.size();i++)nR.push_back(R[i]*-1);
      |                 ~^~~~~~~~~
cipele.cpp:41:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if(idx1==R.size())idx1--;
      |            ~~~~^~~~~~~~~~
cipele.cpp:42:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         if(idx2==nR.size())idx2--;
      |            ~~~~^~~~~~~~~~~
cipele.cpp:51:13: warning: unused variable 'x' [-Wunused-variable]
   51 |         int x = L[i]- abs(L[i]-R[i]);
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 3264 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 3392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 10 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 10 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 480 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 3088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1053 ms 3128 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 3064 KB Time limit exceeded
2 Halted 0 ms 0 KB -