두 개 정도만 멤버 변수로 필요한 경운 pair 사용
#include <string>
#include <vector>
#include <queue>
using namespace std;
int solution(int bridge_length, int weight, vector<int> truck_weights) {
int answer = 0;
int time = 0;
int now_weight = 0;
int cnt = 0;
queue<pair<int, int>> move_truck;
while(1){
if(weight >= now_weight + truck_weights.at(cnt)){
move_truck.push(make_pair(truck_weights[cnt], bridge_length + 1 + time));
now_weight += truck_weights[cnt];
cnt++;
}
if(cnt >= truck_weights.size()){
answer = move_truck.back().second;
break;
}
else{
time++;
if(move_truck.front().second == time + 1){
now_weight -= move_truck.front().first;
move_truck.pop();
}
}
}
return answer;
}