Solution for CCC '13 S2 - Bridge Transport in C++


Feb. 13, 2020 0.533034 seconds C++
#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;

}

Editorial


No editorial for this problem. :(

Original Problem


You can view the original page for this problem on the DMOJ.