Submission #881703

# Submission time Handle Problem Language Result Execution time Memory
881703 2023-12-01T18:44:05 Z spdling A Plus B (IOI23_aplusb) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>

using namespace std;

int A[100005];
int B[100005];

int main() {
  int n;
  
  cin >> n;
  for (int i = 0 ;i < n; ++i) {
    cin >> A[i];
  }
  for (int i = 0 ;i < n; ++i) {
    cin >> B[i];
  }
  vector<int> ans;
  int i = 0, j = 0;
  while (ans.size() < n) {
    ans.push_back(A[i] + B[j]);
    if (A[i] + B[j+1] < A[i+1] + B[j]) {
      ++j;
    } else {
      ++i;
    }
  }
  for (int c : ans) {
    cout << c << " ";
  }
  cout << "\n";
  return 0;
}

Compilation message

aplusb.cpp: In function 'int main()':
aplusb.cpp:21:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |   while (ans.size() < n) {
      |          ~~~~~~~~~~~^~~
/usr/bin/ld: /tmp/ccCNxrRN.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccjRjF5Q.o:aplusb.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccCNxrRN.o: in function `main':
grader.cpp:(.text.startup+0x271): undefined reference to `smallest_sums(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status