Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
17892 2024-04-24 04:14:42 dnt Cheaters Java 106 ms 38836 kb Wrong Answer - 1
Test Cases
CPU Memory Verdict
1 106 ms 38836 kb Wrong Answer
2 - - Skipped
Source Code
program.java
Download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6.  
  7. // Read the number of test cases
  8. int t = sc.nextInt();
  9. for (int i = 0; i < t; i++) {
  10. // Read the number of students who cheated
  11. int n = sc.nextInt();
  12. // Initialize the boolean array to track which student passed the solution
  13. boolean[] passed = new boolean[n + 1];
  14.  
  15. // Read the IDs of the students who cheated
  16. for (int j = 1; j <= n; j++) {
  17. int id = sc.nextInt();
  18. passed[id] = true;
  19. }
  20.  
  21. // Find the student who leaked the solution
  22. int cheaterId = 0;
  23. for (int j = 1; j <= n; j++) {
  24. if (!passed[j]) {
  25. cheaterId = j;
  26. break;
  27. }
  28. }
  29.  
  30. // Output the ID of the cheater who leaked the solution
  31. System.out.println(cheaterId);
  32. }
  33. }
  34. }
  35.  
  36.