제출 #880263

#제출 시각아이디문제언어결과실행 시간메모리
880263MardonbekhazratovA Plus B (IOI23_aplusb)C++17
컴파일 에러
0 ms0 KiB
#include "aplusb.h" #define int long long std::vector<int> smallest_sums(int N, std::vector<int> A, std::vector<int> B) { std::sort(A.begin(),A.end()); std::sort(B.begin(),B.end()); int l=-1,r=1e18; while(r-l>1){ int mid=(l+r)/2; int ans=0; for(int i=0;i<N;i++){ ans+=std::upper_bound(B.begin(),B.end(),mid-A[i])-B.begin(); } if(ans>=N) r=mid; else l=mid; } std::vector<int> ans(N); int j=0; for(int i=0;i<N;i++){ int pos=std::lower_bound(B.begin(),B.end(),r-A[i])-B.begin(); for(int k=0;k<pos;k++){ ans[j++]=A[i]+B[k]; } } while(j<N) ans[j++]=r; std::sort(ans.begin(),ans.end()); return ans; }

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

aplusb.cpp: In function 'std::vector<long long int> smallest_sums(long long int, std::vector<long long int>, std::vector<long long int>)':
aplusb.cpp:5:7: error: 'sort' is not a member of 'std'
    5 |  std::sort(A.begin(),A.end());
      |       ^~~~
aplusb.cpp:6:7: error: 'sort' is not a member of 'std'
    6 |  std::sort(B.begin(),B.end());
      |       ^~~~
aplusb.cpp:12:14: error: 'upper_bound' is not a member of 'std'; did you mean 'lower_bound'?
   12 |    ans+=std::upper_bound(B.begin(),B.end(),mid-A[i])-B.begin();
      |              ^~~~~~~~~~~
      |              lower_bound
aplusb.cpp:26:7: error: 'sort' is not a member of 'std'
   26 |  std::sort(ans.begin(),ans.end());
      |       ^~~~