import java.util.*;
import java.lang.*;
import java.io.*;
// The main method must be in a class named "Main".
class Main {
public static void main(String[] args) {
int[] bandage = {5, 1, 5};
int health = 30;
int[][] attacks = {{2, 10}, {9, 15}, {10, 5}, {11, 5}};
int[] bandage_1 = {3, 2, 7};
int health_1 = 20;
int[][] attacks_1 = {{1, 15}, {5, 16}, {8, 6}};
//System.out.println(solution(bandage, health, attacks));
System.out.println(solution(bandage_1, health_1, attacks_1));
}
public static int solution(int[] bandage, int health, int[][] attacks) {
int curent_health = health;
int loop = 0;
int at_t = 0;
System.out.println("0 / "+curent_health+" / "+loop);
for (int i = 1; i <= attacks[attacks.length - 1][0]; i++) {
if(i == attacks[at_t][0]) {
curent_health -= attacks[at_t][1];
System.out.println(i+" / "+curent_health+"(" + (-attacks[at_t][1]) + ") / "+loop);
if(curent_health <= 0) {
curent_health = -1;
break;
}
loop = 0;
at_t++;
continue;
}
loop++;
curent_health += bandage[1];
if(loop == bandage[0]) {
curent_health += bandage[2];
}
if(curent_health > health) {
curent_health = health;
loop = 0;
}
System.out.println(i+" / "+curent_health+"(+"+(bandage[1] + (loop == bandage[0] ? bandage[2] : 0))+") / "+loop);
}
return curent_health;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: