답안 #1088409

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088409 2024-09-14T10:39:43 Z MateiKing80 A Plus B (IOI23_aplusb) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin() (x).end()

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(all(x));
    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:5:30: error: no match for call to '(std::vector<int>::iterator) (std::vector<int>&)'
    5 | #define all(x) (x).begin() (x).end()
      |                              ^
aplusb.cpp:15:10: note: in expansion of macro 'all'
   15 |     sort(all(x));
      |          ^~~
aplusb.cpp:19:12: warning: address of local variable 'ans' returned [-Wreturn-local-addr]
   19 |     return ans;
      |            ^~~
aplusb.cpp:16:9: note: declared here
   16 |     int ans[100005];
      |         ^~~