The adjacent ropes to achieve the maximum number of ropes of length >= K
Solution
int solution(int K, vector<int> &A) { // write your code in C++11 (g++ 4.8.2) int s = 0; int num = 0; for (size_t i = 0; i < A.size(); i++) { s += A[i]; if (s >= K) { num++; s = 0; } } return num;}