Submission #1088410

# Submission time Handle Problem Language Result Execution time Memory
1088410 2024-09-14T10:41:22 Z MateiKing80 A Plus B (IOI23_aplusb) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;


int* smallest_sums(int n, int a[], int b[])
{
    sort(a, a + n);
    sort(b, b + n);
    vector<int> x;
    for(int i = 0; i < n; i ++)
        for(int j = 0; j < n / (i + 1); j ++)
            x.push_back(a[i] + b[j]);
    sort(x.begin(), x.end());
    int ans[100005];
    for(int i = 0; i < n; i ++)
        ans[i] = x[i];
    return ans;
}

Compilation message

aplusb.cpp: In function 'int* smallest_sums(int, int*, int*)':
aplusb.cpp:18:12: warning: address of local variable 'ans' returned [-Wreturn-local-addr]
   18 |     return ans;
      |            ^~~
aplusb.cpp:15:9: note: declared here
   15 |     int ans[100005];
      |         ^~~
/usr/bin/ld: /tmp/ccFfdV2d.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