#include <string>
#include <vector>
#include <queue>
#include <iostream>
using namespace std;
int solution(int bridge_length, int weight, vector<int> truck_weights) {
int cnt = 0;
int sum = 0;
queue<int> truck_list;
queue<int> curr;
for(int i = 0; i < truck_weights.size(); i++)
truck_list.push(truck_weights[i]);
for(int i = 0; i < bridge_length; i++)
curr.push(0);
do{
//cout<< cnt << ": " << curr.front() << endl;
cnt++;
sum -= curr.front();
curr.pop();
if(truck_list.empty()) continue;
int temp = truck_list.front();
if(sum+temp > weight){
curr.push(0);
continue;
}
curr.push(temp);
sum += temp;
truck_list.pop();
}while(!curr.empty());
return cnt;
}