Submission #959291

# Submission time Handle Problem Language Result Execution time Memory
959291 2024-04-07T21:59:27 Z vjudge1 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) {
    multiset<int> res;
    for(int i=0 ;i<N ;i++) {
        for(int j=0 ;j<N ;j++) {  
            res.insert(A[i]+B[j]); 
        }
    }
    int x[N] ;
    multiset<int>::iterator itr= res.begin();
    int i =0;
    while (N--) {
        x[i] = *itr;
        i++ ;
        ++itr;
    }
    return x;
}

Compilation message

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