Submission #1094321

#TimeUsernameProblemLanguageResultExecution timeMemory
1094321SunbaeA Plus B (IOI23_aplusb)C++17
100 / 100
64 ms4564 KiB
#include <cstdio> #include <vector> #include <algorithm> #include "aplusb.h" typedef long long ll; using namespace std; const int N = 1e5 + 5; vector<int> smallest_sums(int n, vector<int> A, vector<int> B) { ll low = A[0] + B[0], high = A[n-1] + B[n-1], ans; while(low <= high){ ll mid = low + ((high-low)>>1), cnt = 0; for(int i = 0; i<n; ++i){ cnt += upper_bound(B.begin(), B.end(), mid-A[i]) - B.begin(); } if(cnt >= n) high = mid-1, ans = mid; else low = mid+1; } vector<int> v; for(int i = 0, m = 0; i<n; ++i){ for(int j = 0; A[i] + B[j] <= ans && j<n; ++j){ v.push_back(A[i] + B[j]); } } sort(v.begin(), v.end()); v.resize(n); return v; }

Compilation message (stderr)

aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:19:17: warning: unused variable 'm' [-Wunused-variable]
   19 |  for(int i = 0, m = 0; i<n; ++i){
      |                 ^
aplusb.cpp:20:37: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |   for(int j = 0; A[i] + B[j] <= ans && j<n; ++j){
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...