- 津津的储蓄计划
- 2015-01-12 12:03:39 @
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
using namespace std;
struct _Pred{
_Pred(int &present, int &bank): present(present), bank(bank){}
bool operator()(int bud){
present += 300 - bud;
if(present < 0) return true;
bank += 100 * (present / 100);
present %= 100;
return false;
}
int &present, &bank;
};
int main(){
vector<int> budget;
int present = 0, bank = 0;
copy(istream_iterator<int>(cin), istream_iterator<int>(), back_inserter(budget));
vector<int>::iterator itr = find_if(budget.begin(), budget.end(), _Pred(present, bank));
if(itr == budget.end())
cout << bank * 1.2 + present << endl;
else
cout << budget.begin() - itr - 1 << endl;
return 0;
}
1 条评论
-
lcdtyph LV 7 @ 2015-01-12 12:07:21
3 5 7总是WA
- 1