import java.util.Scanner;
class Wandbox {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
if (!scanner.hasNextInt()) {
return;
}
int n = scanner.nextInt();
double[] times = new double[n];
for (int i = 0; i < n; i++) {
times[i] = scanner.nextDouble();
}
double x = scanner.nextDouble();
double y = scanner.nextDouble();
double z = scanner.nextDouble();
double totalDamage = 0.0;
int head = 0;
for (int i = 0; i < n; i++) {
while (times[i] - times[head] > z + 1e-9) {
head++;
}
int activeQuills = i - head;
totalDamage += x + (activeQuills * y);
}
if (totalDamage == (long) totalDamage) {
System.out.println((long) totalDamage);
} else {
System.out.println(totalDamage);
}
scanner.close();
}
}
discussion
3 comments
I left my laptop at home so I was unable to test this
this website already lets you test code lmao
for some reason I cannot run code in this site, I'm on my phone btw
log in to join the discussion.