AcWing 481. 津津的储蓄计划
原题链接
简单
作者:
偷月亮的喵
,
2025-01-11 23:25:46
,
所有人可见
,
阅读 2
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
//total: 存在妈妈那里的总钱数;
//remain: 津津当前剩在自己手里的钱数;
//cur:读入的值,表示当前这个月的生活开销;
int main()
{
int total = 0, remain = 0;
for (int i = 1; i <= 12; i ++ )
{
int cur;
cin >> cur;
if (remain + 300 < cur)
{
total = -i;
break;
}
total = total + (remain - cur + 300) / 100 * 120;
remain = (remain - cur + 300) % 100;
}
if(total > 0) total += remain;
cout << total << endl;
return 0;
}