Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private int[] rateTable;
- Private int getChargingCost(int startHour, int chargeTime){
- int total = 0;
- int position = startHour;
- for(int i = 0; i<= chargeTime-1;i++){
- if(position == 24)
- position = 0;
- total += rateTable[position];
- position++;
- }
- return total;
- }
- Public int getChargeStartTime(int chargeTime){
- int total = 0;
- int answer;
- for (int x = 0;x<=rateTable.length-1;x++){
- int position = x;
- int maybeTotal = 0;
- for(int i = 0; i<= chargeTime-1;i++){
- if(position == 24)
- position = 0;
- maybeTotal += rateTable[position];
- if (i = chargeTime-1){
- if (maybeTotal > total){
- total = maybeTotal
- answer = x;
- }
- }
- position++;
- }
- return x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement