49272023-04-07 13:22:50zolmikiNegáló rendezés (55 pont)javaTime limit exceeded 16/55273ms78624 KiB
import java.util.*;

public class main {
    public static void main(String[] args) {
        // Step 1: Use a Scanner to read input
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] numbers = new int[N];
        for (int i = 0; i < N; i++) {
            numbers[i] = sc.nextInt();
        }

        // Step 2: Use a HashMap instead of a Hashtable
        Map<Integer, Integer> agenda = new HashMap<Integer, Integer>();
        for (int n : numbers) {
            agenda.put(n, agenda.getOrDefault(n, 0) + 1);
        }

        // Step 3: Use a variable to keep track of the minimum value as we go
        int minimum = Integer.MAX_VALUE;
        for (int n : numbers) {
            if (n < minimum) {
                minimum = n;
            }
        }
        agenda.remove(minimum);

        // Step 4: Calculate the result using the formula
        int modulo = (int) Math.pow(10, 9) + 7;
        long result = 1;
        for (int count : agenda.values()) {
            result = (result * (count + 1)) % modulo;
        }

        // Step 5: Print the result
        System.out.println(result);
    }
}
SubtaskSumTestVerdictTimeMemory
base16/55
1Accepted0/0125ms49904 KiB
2Time limit exceeded0/0273ms78624 KiB
3Accepted2/2116ms51728 KiB
4Accepted2/2115ms51828 KiB
5Accepted2/2118ms52048 KiB
6Accepted2/2125ms52944 KiB
7Accepted3/3115ms52856 KiB
8Accepted2/2130ms53488 KiB
9Accepted3/3200ms67016 KiB
10Time limit exceeded0/3256ms75768 KiB
11Time limit exceeded0/3247ms75148 KiB
12Time limit exceeded0/3233ms74876 KiB
13Time limit exceeded0/3230ms74440 KiB
14Time limit exceeded0/3240ms74484 KiB
15Time limit exceeded0/3232ms74164 KiB
16Time limit exceeded0/3237ms73932 KiB
17Time limit exceeded0/3219ms73644 KiB
18Time limit exceeded0/3228ms73612 KiB
19Time limit exceeded0/3221ms73376 KiB
20Time limit exceeded0/3224ms73440 KiB
21Time limit exceeded0/3215ms73264 KiB
22Time limit exceeded0/3226ms73064 KiB