Submission #1094312

#TimeUsernameProblemLanguageResultExecution timeMemory
1094312SunbaeA Plus B (IOI23_aplusb)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define z exit(0) #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(n); for(int i = 0, m = 0; i<n; ++i){ for(int j = 0; A[i] + B[j] <= ans && j<n; ++j){ v[m++] = A[i] + B[j]; } } return v; } signed main(){ int n; scanf("%d", &n); vector<int> A(n), B(n); for(int i = 0, x; i<n; ++i) scanf("%d", &x), A[i] = x; for(int i = 0, x; i<n; ++i) scanf("%d", &x), B[i] = x; vector<int> v = smallest_sums(n, A, B); for(int x: v) printf("%d ", x); }

Compilation message (stderr)

aplusb.cpp: In function 'int main()':
aplusb.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  int n; scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
aplusb.cpp:29:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  for(int i = 0, x; i<n; ++i) scanf("%d", &x), A[i] = x;
      |                              ~~~~~^~~~~~~~~~
aplusb.cpp:30:35: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  for(int i = 0, x; i<n; ++i) scanf("%d", &x), B[i] = x;
      |                              ~~~~~^~~~~~~~~~
aplusb.cpp: In function 'std::vector<int> smallest_sums(int, std::vector<int>, std::vector<int>)':
aplusb.cpp:19:37: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |   for(int j = 0; A[i] + B[j] <= ans && j<n; ++j){
/usr/bin/ld: /tmp/cc5HEoEI.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc3c2BwH.o:aplusb.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status