제출 #710641

#제출 시각아이디문제언어결과실행 시간메모리
710641WarinchaiCipele (COCI18_cipele)C++14
90 / 90
98 ms2556 KiB
#include<bits/stdc++.h> using namespace std; vector<long long>l; vector<long long>r; int check(long long mid){ int j=0; for(int i=0;i<l.size();i++){ while(abs(l[i]-r[j])>mid){ j++; if(j>r.size()-1){ break; } } if(j>r.size()-1){ break; } if(i==l.size()-1){ return 1; } j++; if(j>r.size()-1){ break; } } return 0; } int check2(long long mid){ int j=0; for(int i=0;i<r.size();i++){ while(abs(r[i]-l[j])>mid){ j++; if(j>l.size()-1){ break; } } if(j>l.size()-1){ break; } if(i==r.size()-1){ return 1; } j++; if(j>l.size()-1){ break; } } return 0; } int main(){ int a,b; cin>>a>>b; for(int i=0;i<a;i++){ int x; cin>>x; l.push_back(x); } for(int i=0;i<b;i++){ int x; cin>>x; r.push_back(x); } sort(l.begin(),l.end()); sort(r.begin(),r.end()); long long st=0,en=10e9,ans=0,mid; while(st<=en){ mid=(st+en)/2; if(l.size()>r.size()){ if(check2(mid)){ en=mid-1; ans=mid; }else{ st=mid+1; } }else{ if(check(mid)){ en=mid-1; ans=mid; }else{ st=mid+1; } } } cout<<ans; }

컴파일 시 표준 에러 (stderr) 메시지

cipele.cpp: In function 'int check(long long int)':
cipele.cpp:7:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for(int i=0;i<l.size();i++){
      |              ~^~~~~~~~~
cipele.cpp:10:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |    if(j>r.size()-1){
      |       ~^~~~~~~~~~~
cipele.cpp:14:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   if(j>r.size()-1){
      |      ~^~~~~~~~~~~
cipele.cpp:17:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |   if(i==l.size()-1){
      |      ~^~~~~~~~~~~~
cipele.cpp:21:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   if(j>r.size()-1){
      |      ~^~~~~~~~~~~
cipele.cpp: In function 'int check2(long long int)':
cipele.cpp:29:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i=0;i<r.size();i++){
      |              ~^~~~~~~~~
cipele.cpp:32:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |    if(j>l.size()-1){
      |       ~^~~~~~~~~~~
cipele.cpp:36:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   if(j>l.size()-1){
      |      ~^~~~~~~~~~~
cipele.cpp:39:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   if(i==r.size()-1){
      |      ~^~~~~~~~~~~~
cipele.cpp:43:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   if(j>l.size()-1){
      |      ~^~~~~~~~~~~
#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...