#include <string>
#include <vector>
#include <queue>
usingnamespacestd;intsolution(intbridge_length,intweight,vector<int>truck_weights){intanswer=0;inttotal_weight=0;inttruck_idx=0;queue<int>q;for(inti=0;i<bridge_length;i++){q.push(0);}// for first input -> q = [0, 0]while(!q.empty()){answer++;// increse timetotal_weight-=q.front();q.pop();// if there's more truckif(truck_idx<truck_weights.size()){// if more truck can get on the bridgeif(total_weight+truck_weights[truck_idx]<=weight){total_weight+=truck_weights[truck_idx];q.push(truck_weights[truck_idx]);truck_idx++;}// if not push 0 in qeueuelse{q.push(0);}}}returnanswer;}