답안 #472451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472451 2021-09-13T15:26:02 Z Beboo44 Cipele (COCI18_cipele) C++17
18 / 90
104 ms 3396 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 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 a;
 ll b;
 if(leftt.size()>rightt.size()){

 while(leftt.size()!=rightt.size()){
    if(abs(leftt[0]-rightt[0])>abs(rightt[m-1]-leftt[n-1])){
        leftt.erase(leftt.begin());
    }
    else{
        leftt.erase(leftt.begin()+n-1);
    }
 }
 }
 else if (rightt.size()>leftt.size()){

 while(leftt.size()!=rightt.size()){
    if(abs(leftt[0]-rightt[0])>abs(rightt[m-1]-leftt[n-1])){
        rightt.erase(rightt.begin());
    }
    else{
        rightt.erase(rightt.begin()+m-1);
    }
 }
 }

 ll ans=0;
 for(int i=0; i<leftt.size(); ++i){
    ans=max(ans,abs(leftt[i]-rightt[i]));
 }
 cout<<ans;


    return 0;
}

Compilation message

cipele.cpp: In function 'int main()':
cipele.cpp:57:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i=0; i<leftt.size(); ++i){
      |               ~^~~~~~~~~~~~~
cipele.cpp:31:5: warning: unused variable 'a' [-Wunused-variable]
   31 |  ll a;
      |     ^
cipele.cpp:32:5: warning: unused variable 'b' [-Wunused-variable]
   32 |  ll b;
      |     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 2124 KB Output is correct
2 Correct 104 ms 2108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 2124 KB Output is correct
2 Correct 101 ms 2016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 332 KB Output is correct
2 Runtime error 6 ms 844 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 81 ms 3232 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 90 ms 3396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 80 ms 3052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -