Advertisement
Guest User

Untitled

a guest
May 20th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.Objects;
  5. import java.util.Scanner;
  6.  
  7.  
  8. public class Main {
  9. public static int povtoruvanje(String str, String findStr) {
  10. int lastIndex = 0;
  11. int count = 0;
  12.  
  13. while (lastIndex != -1) {
  14.  
  15. lastIndex = str.indexOf(findStr, lastIndex);
  16.  
  17. if (lastIndex != -1) {
  18. count++;
  19. lastIndex += findStr.length();
  20. }
  21. }
  22. return count;
  23. }
  24.  
  25. public static void main(String[] args) throws IOException {
  26. Scanner kb = new Scanner(System.in);
  27. String numbers = kb.nextLine();
  28. String[] tmp = numbers.split(" ");
  29. int N = Integer.valueOf(tmp[0]);
  30. int T = Integer.valueOf(tmp[1]);
  31. int K = Integer.valueOf(tmp[2]);
  32. int bolni = 0;
  33. int zdravi = 0;
  34. for(int i=0; i<N; i++){
  35. String s = kb.next();
  36. int t = 0;
  37. for(int j=0; j<K; j++){
  38. String a = kb.next();
  39. int b = kb.nextInt();
  40. int k = povtoruvanje(s, a);
  41. if(k > b) t++;
  42. }
  43. if(t > T) bolni++;
  44. else zdravi++;
  45. }
  46.  
  47. System.out.println(bolni + " " + zdravi);
  48.  
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement