Nathan Coulas

CCC '13 S2 - Bridge Transport

ccc13s2 CPP17 13 Feb, 2020 0.533s 5 points

Source Code

#include <iostream>
#include <string>
using namespace std;



int main(){

	int w, n, app, c = 0;
	cin >> w >> n;
	int cars[w + 3] = { 0 };

	for(int i = 0; i < n; i++){
		cin >> app;
		cars[i + 3] = app;

	}

		for(int i = 0; i < n; i++){

			if(cars[i] + cars[i + 1] + cars[i + 2] + cars[i + 3] <= w){
				c++;
			}else{
				break;
			}


		}

	cout << c << endl;

}