Submission #472467

# Submission time Handle Problem Language Result Execution time Memory
472467 2021-09-13T15:50:22 Z Beboo44 Cipele (COCI18_cipele) C++17
27 / 90
108 ms 3644 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[rightt.size()-1]-leftt[leftt.size()-1])){
        leftt.erase(leftt.begin());
    }
    else{
        leftt.erase(leftt.begin()+leftt.size()-1);
    }
 }
 }
 else if (rightt.size()>leftt.size()){
 while(leftt.size()!=rightt.size()){
    if(abs(leftt[0]-rightt[0])>abs(rightt[rightt.size()-1]-leftt[leftt.size()-1])){
        rightt.erase(rightt.begin());
    }
    else{
        rightt.erase(rightt.begin()+rightt.size()-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:56:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  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;
      |     ^
# Verdict Execution time Memory Grader output
1 Correct 79 ms 3372 KB Output is correct
2 Correct 108 ms 3644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 3636 KB Output is correct
2 Correct 98 ms 3524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 5 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 81 ms 2960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 3268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 94 ms 2940 KB Output isn't correct
2 Halted 0 ms 0 KB -