8320 | 2024-01-14 17:52:21 | qertend | Virágos rét (50 pont) | java | Forditási hiba |
import java.io.IOException;
import mester.IO;
/**
* feladat 1
*/
public class main {
public static void main(String[] args) throws IOException {
IO io = new IO();
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) io.write((N)*(N+1)/2); //write the sum of all positive integers up to N (inclusive)
else io.write(0);
io.close();
}
}
exit status 1