fork(2) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int min_ans, max_ans, x, k, t, num1, num2, num, a[4001], i;
  7.  
  8. int main()
  9.  
  10. {
  11. scanf("%d%d", &x, &k);
  12. for (int i = 0; i < k; i++)
  13. {
  14. scanf("%d", &t);
  15. if (t == 1)
  16. {
  17. scanf("%d%d", &num1, &num2);
  18. a[num1] = 1;
  19. a[num2] = 1;
  20. }
  21. if (t == 2)
  22. {
  23. scanf("%d", &num);
  24. a[num] = 1;
  25. }
  26. }
  27. i = 1;
  28. while (i < x)
  29. {
  30. if (a[i] == 0)
  31. {
  32. if (i + 1 < x && a[i + 1] == 0)
  33. {
  34. a[i] = 1;
  35. a[i + 1] = 1;
  36. min_ans++;
  37. max_ans += 2;
  38. i+=2;
  39. }
  40. else {
  41. a[i] = 1;
  42. max_ans++;
  43. min_ans++;
  44. i++;
  45. }
  46. }
  47. else i++;
  48. }
  49. printf("%d %d", min_ans, max_ans);
  50. }
Success #stdin #stdout 0s 3360KB
stdin
Standard input is empty
stdout
0 0