Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
17895 2024-04-24 04:15:40 dnt Cheaters Java 121 ms 38664 kb Wrong Answer - 1
Test Cases
CPU Memory Verdict
1 121 ms 38664 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.  
  13. // Initialize the boolean array to track which student passed the solution
  14. boolean[] passed = new boolean[n + 1];
  15.  
  16. // Read the IDs of the students who cheated and mark them as passed
  17. for (int j = 1; j <= n; j++) {
  18. int id = sc.nextInt();
  19. passed[id] = true;
  20. }
  21.  
  22. // Find the student who leaked the solution
  23. int cheaterId = 0;
  24. for (int j = 1; j <= n; j++) {
  25. if (!passed[j]) {
  26. cheaterId = j;
  27. break;
  28. }
  29. }
  30.  
  31. // Output the ID of the cheater who leaked the solution
  32. System.out.print(cheaterId + " ");
  33. }
  34. }
  35. }
  36.