CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Kortit
Sender:TapaniS
Submission time:2020-09-25 20:10:06 +0300
Language:Java
Status:COMPILE ERROR

Compiler report

input/kortit.java:15: error: cannot find symbol
		for (int k = 0; k < tests; i++) {
		                           ^
  symbol:   variable i
  location: class kortit
input/kortit.java:16: error: variable qty is already defined in method main(String[])
			int qty = input.nextInt() / 2;
			    ^
2 errors

Code

import java.util.*;
public class kortit {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int tests = input.nextInt();
int[] qty = new int[tests];
int[] ans = new int[tests];
int card = 0;
for (int k = 0; k < tests; i++) {
int qty = input.nextInt() / 2;
int winners = 0;
for (int i = 0; i < qty; i++) {
card = input.nextInt();
if (card > winners + i + 1) winners++;
}
ans[k] = winners;
}
for (int i = 0; i < tests; i++) {
System.out.println(ans[i]);
}
input.close();
}
}