class Bank {
public:
vector<long long>balance;
int maxID,minID;
Bank(vector<long long>& _balance) {
balance.push_back(0);
for(auto x:_balance) balance.push_back(x);
minID=1;
maxID=balance.size()-1;
}
bool check(int id){
return id>=minID && id<=maxID;
}
bool transfer(int account1, int account2, long long money) {
if( !check(account1) || !check(account2) ) return false;
if(balance[account1]>=money){
balance[account1]-=money;
balance[account2]+=money;
return true;
}
return false;
}
bool deposit(int account, long long money) {
if( !check(account) ) return false;
balance[account]+=money;
return true;
}
bool withdraw(int account, long long money) {
if( !check(account) ) return false;
if(balance[account]>=money){
balance[account]-=money;
return true;
}
return false;
}
};
/**
* Your Bank object will be instantiated and called as such:
* Bank* obj = new Bank(balance);
* bool param_1 = obj->transfer(account1,account2,money);
* bool param_2 = obj->deposit(account,money);
* bool param_3 = obj->withdraw(account,money);
*/