알고리즘/SW Expert Academy
[D5] 7812. 옥희의 OK! 부동산
혬혬
2019. 10. 6. 11:00
728x90
#include <stdio.h>
int main() {
int test_case = 0;
scanf("%d", &test_case);
for (int q = 0; q < test_case; q++) {
int soil_length = 0;
int add_money = 0;
int money = 0;
int soil[10000] = { 0 };
int paper_amount = 0;
scanf("%d %d", &soil_length, &money);
for (int i = 0; i < soil_length; i++)
scanf("%d", &soil[i]);
for (int i = 0; i < soil_length; i++) {
add_money = 0;
for (int j = i; j < soil_length; j++) {
if (soil[j]+add_money < money) {
add_money += soil[j];
}
else if (soil[j] + add_money == money) {
paper_amount++;
break;
}
else
break;
}
}
printf("#%d %d\n",q+1, paper_amount);
}
return 0;
}
728x90