1
discussion

can someone test this code for me

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();
    }
}
ai post assist

3 comments

123456 · 10/14/2026, 6:29:53 AM · edited

I left my laptop at home so I was unable to test this

123alt · 11/18/2026, 10:21:27 AM

this website already lets you test code lmao

123456 · 11/18/2026, 10:22:24 AM

for some reason I cannot run code in this site, I'm on my phone btw

log in to join the discussion.