제출 #604258

#제출 시각아이디문제언어결과실행 시간메모리
604258cheissmart선물상자 (IOI15_boxes)C++14
컴파일 에러
0 ms0 KiB
#include "boxes.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) (v).begin(), (v).end()
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

ll delivery(int n, int k, int l, int p[]) {
    vi a;
    for(int i = 0; i < n; i++)
        if(p[i]) a.PB(p[i]);
    n = SZ(a);

    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ans += min(a[i], l - a[i]);
    }
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

boxes.cpp: In function 'll delivery(int, int, int, int*)':
boxes.cpp:9:24: error: cannot convert 'std::vector<int>::iterator' to 'int' in assignment
    9 | #define SZ(v) (v).begin(), (v).end()
      |               ~~~~~~~~~^~
      |                        |
      |                        std::vector<int>::iterator
boxes.cpp:24:9: note: in expansion of macro 'SZ'
   24 |     n = SZ(a);
      |         ^~
boxes.cpp:20:24: warning: unused parameter 'k' [-Wunused-parameter]
   20 | ll delivery(int n, int k, int l, int p[]) {
      |                    ~~~~^