Submission #472229

#TimeUsernameProblemLanguageResultExecution timeMemory
472229MamdouhNCipele (COCI18_cipele)C++14
18 / 90
1091 ms3392 KiB
#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 (stderr)

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]);
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...