83222024-01-14 17:54:40qertendVirágos rét (50 pont)javaTime limit exceeded 25/50287ms78904 KiB
import java.io.IOException;
import java.util.Scanner;

/**
 * //njudge compatible version
 */
public class main {

    public static void main(String[] args) throws IOException {
        Scanner io = new Scanner(System.in);
        int retekSzama = io.nextInt();
        int K = io.nextInt();
        int szabadRetek = 0;

        for (int i = 0; i < retekSzama; i++) {
            if (io.nextInt() == 1) szabadRetek++;
        }
        int N = szabadRetek-K+1;
        if (szabadRetek >= K) System.out.println((N)*(N+1)/2); //write the sum of all positive integers up to N (inclusive)
        else System.out.println(0);

        io.close();
    }
}
SubtaskSumTestVerdictTimeMemory
base25/50
1Accepted0/0120ms50092 KiB
2Accepted0/0116ms50216 KiB
3Time limit exceeded0/0287ms78904 KiB
4Accepted2/2122ms51608 KiB
5Accepted2/2119ms52088 KiB
6Accepted2/2130ms52744 KiB
7Accepted3/3127ms53024 KiB
8Accepted3/3126ms53372 KiB
9Accepted3/3123ms53820 KiB
10Accepted2/2141ms54648 KiB
11Accepted3/3170ms59792 KiB
12Accepted2/2173ms60692 KiB
13Accepted3/3182ms62668 KiB
14Time limit exceeded0/2247ms75004 KiB
15Time limit exceeded0/2250ms74820 KiB
16Time limit exceeded0/3252ms74260 KiB
17Time limit exceeded0/3234ms74092 KiB
18Time limit exceeded0/3244ms74048 KiB
19Time limit exceeded0/3238ms73844 KiB
20Time limit exceeded0/3252ms73904 KiB
21Time limit exceeded0/3259ms73584 KiB
22Time limit exceeded0/3252ms73992 KiB