You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
719 B

#include <bits/stdc++.h>
using namespace std;
int c, x, y;
int main() {
// 12个月
for (int i = 1; i <= 12; i++) {
//每个月领取到300元钱
x += 300;
scanf("%d", &c);
//如果不够花
if (c > x) {
printf("%d\n", -i);
exit(0);
}
//如果花完还剩100元以上
if (x - c >= 100) {
//将整百的钱,存到妈妈处
y += (x - c) / 100 * 100;
//津津的钱减少了
x = (x - c) % 100;
} else
//直接花掉c元
x = x - c;
}
//如果够花
printf("%d\n", x + (int)(y * 1.2));
return 0;
}