https://programmers.co.kr/learn/courses/30/lessons/49995
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<int> cookie) {
int answer = 0;
for (int i = 1; i < cookie.size(); i++) {
int left = i-1;
int right = i;
int tmp1 = cookie[left];
int tmp2 = cookie[right];
while (true) {
if (tmp1 == tmp2) {
answer = max(answer, tmp1);
right++;
if (right < cookie.size()) {
tmp2 += cookie[right];
}
else {
break;
}
left--;
if (left >= 0) {
tmp1 += cookie[left];
}
else {
break;
}
}
if (tmp1 > tmp2) {
right++;
if (right < cookie.size()) {
tmp2 += cookie[right];
}
else {
break;
}
}
else if (tmp1 < tmp2) {
left--;
if (left >= 0) {
tmp1 += cookie[left];
}
else {
break;
}
}
}
}
return answer;
}