#include <numeric> #define ALL(v) (v).begin(), (v).end() ... ll childSweetSum = accumulate(ALL(a), 0LL); // long long or int childSweetSum = accumulate(ALL(a), 0);
- include numericが必要
- begin, endは定型なのでALL
- long longは初期値に 0LL と入れる
#include <numeric> #define ALL(v) (v).begin(), (v).end() ... ll childSweetSum = accumulate(ALL(a), 0LL); // long long or int childSweetSum = accumulate(ALL(a), 0);