Statistics

Problem Statement for "GreaterGameDiv2"

Problem Statement

Cat Snuke and wolf Sothe are playing the Greater Game. The game is played with cards. Each card has a number written on it. There are 2N cards. The numbers on the cards are the integers between 1 and 2N, inclusive.


At the beginning of the game, each player gets N of the cards and chooses the order in which he wants to play them. The game then consists of N turns. In each turn, both players play one of their cards simultaneously. The player who revealed the card with the larger number gets a point.


You are given two int[]s: snuke and sothe. The elements of snuke are the numbers on the cards Snuke is going to play, in order. Similarly, the elements of sothe are the numbers on the cards Sothe is going to play, in order. Compute and return the number of points Snuke will have at the end of the game.

Definition

Class:
GreaterGameDiv2
Method:
calc
Parameters:
int[], int[]
Returns:
int
Method signature:
int calc(int[] snuke, int[] sothe)
(be sure your method is public)

Constraints

  • N will be between 1 and 50, inclusive.
  • snuke and sothe will contain exactly N elements each.
  • Each integer in snuke and sothe will be between 1 and 2N, inclusive.
  • The integers in snuke and sothe will be distinct.

Examples

  1. {1,3}

    {4,2}

    Returns: 1

    Snuke loses the first round because 1 is less than 4. Snuke then wins the second round because 3 is greater than 2.

  2. {1,3,5,7,9}

    {2,4,6,8,10}

    Returns: 0

  3. {2}

    {1}

    Returns: 1

  4. {1}

    {2}

    Returns: 0

  5. {1,2,3,4,5}

    {6,7,8,9,10}

    Returns: 0

  6. {2}

    {1}

    Returns: 1

  7. {3,4}

    {1,2}

    Returns: 2

  8. {3,4,5}

    {2,1,6}

    Returns: 2

  9. {3,2,5,4}

    {6,7,1,8}

    Returns: 1

  10. {8,1,9,10,2}

    {3,7,5,6,4}

    Returns: 3

  11. {11,9,7,4,5,8}

    {12,3,6,2,1,10}

    Returns: 4

  12. {13,10,2,12,1,9,3}

    {4,6,14,8,11,5,7}

    Returns: 4

  13. {11,15,2,4,1,14,16,7}

    {6,5,9,12,8,3,13,10}

    Returns: 4

  14. {3,1,16,4,11,6,13,9,15}

    {5,12,14,7,17,18,8,10,2}

    Returns: 3

  15. {3,5,9,16,14,20,15,17,13,2}

    {6,18,1,8,7,10,11,19,12,4}

    Returns: 6

  16. {16,1,21,18,3,9,6,10,19,20,15}

    {12,14,2,22,8,7,11,13,5,4,17}

    Returns: 5

  17. {20,12,4,22,7,15,18,1,14,11,5,13}

    {6,3,10,9,21,2,23,19,24,16,17,8}

    Returns: 5

  18. {26,23,15,5,10,11,8,17,9,13,6,22,16}

    {20,3,19,21,14,1,2,7,12,4,25,18,24}

    Returns: 7

  19. {19,18,23,2,9,16,20,12,6,27,10,26,22,21}

    {17,7,13,15,4,1,24,14,3,5,11,8,28,25}

    Returns: 8

  20. {11,6,8,30,22,26,19,9,5,27,24,21,7,25,15}

    {13,4,28,23,20,10,16,2,18,12,1,17,29,3,14}

    Returns: 11

  21. {20,6,23,26,13,12,5,7,32,8,27,11,21,10,15,14}

    {4,24,17,3,31,29,25,2,19,16,30,18,9,22,1,28}

    Returns: 7

  22. {2,18,8,23,31,4,20,9,3,24,5,15,21,27,29,13,6}

    {11,16,14,26,10,22,12,33,19,32,17,30,1,25,34,7,28}

    Returns: 6

  23. {8,15,1,20,6,14,32,28,2,35,29,25,17,7,13,10,31,19}

    {30,9,16,26,3,11,34,22,27,5,36,21,4,33,23,24,18,12}

    Returns: 9

  24. {28,38,29,9,22,31,21,8,37,11,6,25,30,15,1,27,5,24,19}

    {16,23,26,33,13,4,3,7,12,17,35,32,34,2,10,20,18,36,14}

    Returns: 11

  25. {32,28,31,22,3,1,11,30,4,16,24,6,37,19,20,39,25,12,18,2}

    {7,10,33,35,23,14,40,26,38,29,13,5,8,36,17,34,9,27,15,21}

    Returns: 10

  26. {6,35,5,33,39,29,21,34,18,30,9,22,32,8,42,16,36,12,40,24,4}

    {11,19,25,28,20,23,27,10,2,3,26,38,1,41,17,31,37,13,15,7,14}

    Returns: 11

  27. {1,22,6,11,34,13,15,28,27,42,9,18,24,30,40,12,36,35,17,10,23,39}

    {19,5,16,31,14,7,4,26,32,33,44,8,20,3,25,29,41,37,2,21,38,43}

    Returns: 11

  28. {23,14,44,3,27,39,6,11,16,37,34,43,26,29,40,36,18,7,30,5,15,22,19}

    {12,31,20,8,33,38,2,9,13,35,46,17,4,42,41,24,1,32,21,25,45,28,10}

    Returns: 13

  29. {9,17,39,46,40,10,23,13,3,5,2,41,28,14,4,24,33,42,6,32,48,47,7,8}

    {36,30,11,18,29,16,37,20,26,21,43,35,38,44,34,15,31,1,45,25,22,19,27,12}

    Returns: 10

  30. {23,25,44,42,18,9,26,16,39,50,20,19,6,49,2,1,41,43,22,29,28,4,47,31,21}

    {17,35,34,36,30,12,27,13,10,8,24,11,38,32,48,3,33,15,46,40,37,7,45,14,5}

    Returns: 13

  31. {14,9,19,17,35,12,31,2,37,48,3,1,44,15,39,46,38,18,25,51,13,10,40,49,52,24}

    {41,21,28,5,33,7,45,47,6,43,29,8,4,34,30,42,23,36,16,27,50,11,26,32,20,22}

    Returns: 15

  32. {28,52,9,34,16,13,32,40,17,42,7,46,18,3,20,22,51,48,36,1,50,10,14,25,26,54,19}

    {23,29,27,15,8,43,30,39,4,11,37,2,41,38,49,24,35,6,47,21,5,53,45,44,33,12,31}

    Returns: 13

  33. {11,2,33,3,14,46,1,54,39,7,47,32,10,41,56,15,37,18,9,53,38,44,29,22,4,35,49,50}

    {8,19,6,45,48,5,43,36,55,23,24,13,30,34,21,52,12,27,16,31,20,42,40,28,51,25,26,17}

    Returns: 15

  34. {22,21,46,23,1,47,42,12,27,33,26,31,15,44,58,25,11,10,8,36,54,52,53,48,39,19,32,40,56}

    {28,20,45,16,55,30,14,2,13,5,37,51,17,3,7,29,57,34,41,50,4,18,38,49,6,9,43,24,35}

    Returns: 17

  35. {41,27,7,22,36,45,9,49,6,17,54,15,55,21,53,35,16,8,34,10,57,25,46,44,40,19,52,43,20,56}

    {32,33,30,2,12,3,24,42,38,11,50,29,47,37,18,4,26,23,14,1,60,13,28,39,48,5,51,58,31,59}

    Returns: 17

  36. {48,58,37,34,12,11,35,53,10,8,46,33,50,51,41,15,52,25,28,60,22,32,54,5,59,21,30,40,20,45,6}

    {27,13,18,3,17,36,55,24,49,43,42,62,26,4,14,47,61,31,38,29,16,57,9,2,23,1,56,39,7,19,44}

    Returns: 18

  37. {8,45,44,9,33,50,14,13,48,42,30,12,36,57,64,39,60,31,55,2,59,41,46,40,52,23,51,7,38,29,27,17}

    {4,62,10,43,1,18,22,6,56,49,20,21,3,47,54,28,11,53,5,16,25,58,34,63,37,26,61,19,32,15,35,24}

    Returns: 17

  38. {14,6,8,36,13,58,30,45,40,56,65,9,54,66,48,44,34,43,37,26,5,19,42,33,1,46,63,7,31,10,22,39,62}

    {18,17,20,35,38,52,41,53,64,60,59,2,15,24,49,57,51,16,11,29,4,3,23,25,28,32,61,55,47,27,50,21,12}

    Returns: 16

  39. {5,55,37,12,46,7,33,31,36,22,1,11,47,38,53,62,56,14,58,30,3,29,17,52,13,20,42,8,16,51,63,68,19,64}

    {43,18,15,40,45,21,24,66,59,39,61,50,32,65,25,23,26,28,60,41,67,44,2,4,57,35,54,49,27,10,48,9,34,6}

    Returns: 14

  40. {60,32,30,56,44,31,14,55,18,51,42,19,61,47,50,17,29,37,62,7,58,64,36,53,41,70,54,24,68,21,4,1,39,20,27}

    {10,28,22,59,6,26,40,33,2,57,65,48,16,23,15,9,67,34,3,5,63,69,12,13,11,8,35,49,45,46,38,52,25,43,66}

    Returns: 21

  41. {52,51,1,39,19,65,69,26,40,8,10,45,54,72,30,17,4,41,60,2,33,47,56,18,7,36,50,11,24,49,13,62,42,68,28,20}

    {37,31,22,53,67,48,15,35,71,58,34,66,6,46,9,61,21,14,23,63,25,3,12,44,70,27,5,32,29,55,43,64,16,57,38,59}

    Returns: 16

  42. {11,35,39,52,48,8,15,72,23,13,34,37,43,40,74,21,66,59,73,32,41,24,5,44,62,60,26,31,30,18,47,67,7,10,69,28,6}

    {53,19,71,50,22,33,51,42,64,1,45,65,4,49,46,27,61,36,20,25,12,58,16,57,68,14,56,29,55,9,54,63,70,2,38,17,3}

    Returns: 20

  43. {59,2,20,28,76,33,64,71,63,9,49,32,47,25,26,53,57,55,5,1,34,50,17,6,7,40,30,16,41,29,8,14,46,45,61,66,67,15}

    {19,11,24,72,75,74,58,44,4,39,38,62,31,70,73,48,22,65,60,13,51,23,36,18,52,12,68,54,43,3,69,27,21,10,37,56,35,42}

    Returns: 17

  44. {31,65,27,43,13,56,57,49,28,33,39,54,58,8,63,12,18,32,29,66,22,75,46,61,3,20,59,73,34,71,47,19,16,24,44,1,52,7,30}

    {67,50,69,74,10,36,6,15,2,4,53,17,77,48,41,70,11,40,5,68,35,38,76,37,62,51,21,9,78,55,60,26,64,25,23,45,14,72,42}

    Returns: 18

  45. {13,31,9,75,23,38,58,61,7,24,43,17,29,79,19,45,44,39,66,2,56,15,46,27,5,32,63,36,80,49,8,51,74,6,25,50,73,35,64,69}

    {42,33,21,22,60,78,30,62,20,55,4,76,28,1,67,3,54,16,59,37,40,41,34,52,26,18,47,70,71,53,12,48,57,10,14,72,11,77,65,68}

    Returns: 18

  46. {29,32,34,54,57,13,42,18,8,49,22,45,27,78,9,41,11,71,72,47,35,64,80,68,75,82,67,14,25,55,58,39,30,33,19,2,20,52,61,5,26}

    {36,73,28,40,1,62,43,66,21,63,48,76,3,69,70,17,60,6,24,46,51,15,16,65,4,38,10,79,74,23,7,37,12,59,44,31,56,53,77,81,50}

    Returns: 19

  47. {81,16,83,22,69,38,76,59,77,29,68,23,84,75,33,65,31,17,30,8,43,55,78,18,80,26,13,50,48,62,6,63,73,10,74,52,7,4,61,67,12,15}

    {64,20,14,3,21,36,24,40,82,27,42,9,49,60,70,39,41,45,32,46,72,25,71,11,53,54,47,57,79,19,58,44,5,2,1,37,56,34,35,66,28,51}

    Returns: 25

  48. {9,82,11,1,53,12,45,15,72,33,46,36,34,64,69,32,76,37,47,20,55,10,54,63,8,18,52,38,21,44,29,30,71,83,81,67,31,35,49,24,66,23,26}

    {68,14,80,17,75,65,5,4,48,85,50,6,70,19,60,13,25,58,84,2,62,57,39,86,28,41,78,59,56,73,77,42,61,74,40,7,3,16,79,27,51,22,43}

    Returns: 19

  49. {10,7,70,24,1,73,87,5,81,79,55,37,83,2,50,41,78,74,76,54,4,14,33,31,39,85,77,22,43,48,8,9,44,21,32,63,20,29,56,53,36,80,13,6}

    {27,26,51,71,30,38,86,69,52,28,64,3,16,12,60,72,15,45,65,40,25,58,82,19,11,34,88,75,42,23,17,35,84,47,61,46,62,49,59,67,68,18,66,57}

    Returns: 18

  50. {2,58,23,49,78,42,71,8,84,83,57,30,63,75,46,67,31,20,10,19,24,52,68,45,90,66,32,82,87,37,13,72,4,60,70,33,86,51,39,28,9,61,41,5,54}

    {29,47,62,85,3,7,18,21,76,17,80,16,40,36,55,35,53,11,14,88,12,59,74,69,43,89,79,34,22,65,27,1,73,15,26,44,50,56,6,77,81,38,25,48,64}

    Returns: 22

  51. {86,24,35,29,25,30,58,13,78,40,45,7,26,60,3,14,9,57,59,82,68,22,44,88,5,70,20,36,11,63,27,65,10,42,53,79,61,56,77,83,76,1,32,34,75,8}

    {67,33,2,19,16,50,41,84,43,52,92,38,21,51,71,80,62,55,47,54,66,87,6,46,17,72,89,37,15,31,69,73,49,85,81,12,74,23,28,39,64,4,18,48,90,91}

    Returns: 21

  52. {26,64,58,48,90,13,80,93,38,72,71,55,83,57,62,92,29,82,52,44,41,19,67,50,45,20,85,4,16,42,59,8,54,12,30,94,49,33,73,56,84,2,11,81,65,31,68}

    {25,77,23,1,28,35,5,61,36,88,51,89,78,14,47,24,6,70,39,40,46,21,74,76,87,53,63,66,60,75,43,32,3,34,27,10,7,15,18,91,9,17,37,79,86,69,22}

    Returns: 27

  53. {79,81,51,78,95,12,37,90,59,32,9,52,85,71,63,4,87,65,15,2,69,36,75,57,44,21,40,20,29,47,18,39,73,88,46,70,42,6,83,62,48,80,8,84,66,86,14,30}

    {50,17,5,41,34,49,27,26,38,96,53,3,1,77,24,25,91,23,13,22,11,74,35,68,67,76,58,19,43,64,89,60,45,10,72,33,31,7,82,28,56,94,61,92,55,54,93,16}

    Returns: 25

  54. {56,76,25,57,60,80,22,15,21,2,6,29,89,37,81,46,43,44,52,58,9,98,92,16,1,72,77,70,78,84,26,53,13,11,74,96,12,14,91,95,90,73,75,30,97,31,39,65,62}

    {27,51,49,41,38,93,82,83,79,36,3,45,94,8,10,34,48,5,88,85,33,68,66,59,42,20,4,19,32,7,50,35,28,40,18,54,64,24,63,86,47,87,17,69,61,67,55,23,71}

    Returns: 25

  55. {22,61,25,98,64,29,7,48,77,82,44,24,92,32,53,9,55,68,11,87,40,70,42,69,65,13,14,88,90,21,10,76,34,91,6,60,54,56,81,57,86,94,23,37,19,58,80,85,59,27}

    {36,52,89,3,93,74,47,95,45,73,28,72,83,79,5,16,49,97,17,75,1,43,33,8,38,50,35,41,67,15,62,31,100,46,12,30,84,26,63,20,18,96,51,39,71,99,2,66,4,78}

    Returns: 27

  56. {81,52,25,2,38,26,65,34,89,56,41,17,10,22,44,47,85,51,93,64,24,91,27,72,73,39,59,15,4,53,61,40,69,57,18,1,90,35,74,68,88,32,3,6,77,95,14,11,97,67}

    {55,79,36,33,60,84,83,96,50,16,37,92,86,48,76,70,43,62,13,7,31,23,20,94,98,29,66,9,46,87,8,80,58,99,75,100,78,42,45,30,49,63,5,71,28,54,12,82,21,19}

    Returns: 22

  57. {72,68,55,30,24,97,52,73,100,25,9,47,89,5,42,14,6,58,94,59,43,54,28,71,13,7,53,12,56,36,10,70,95,39,46,90,86,40,16,31,82,83,34,29,61,11,27,64,37,87}

    {65,66,41,45,19,67,99,92,74,63,81,80,96,78,35,15,21,84,60,18,1,57,33,8,79,49,20,2,3,17,76,44,23,69,93,4,50,98,51,38,32,48,88,22,26,85,75,62,91,77}

    Returns: 25

  58. {50,93,1,98,58,12,75,68,10,71,53,17,47,9,36,42,67,20,33,6,80,15,22,32,38,31,99,2,59,13,14,95,35,52,25,76,40,46,3,73,74,19,83,70,55,26,60,65,85,18}

    {72,100,88,43,21,66,91,8,54,24,11,48,34,28,4,87,5,81,23,30,82,79,27,16,45,69,84,56,97,64,86,63,90,94,92,51,44,78,61,41,89,96,7,37,29,49,62,39,77,57}

    Returns: 19

  59. {63,12,49,93,66,46,22,4,36,54,10,84,86,34,44,38,1,3,30,99,64,13,14,92,8,89,19,65,97,50,85,71,52,96,81,23,27,91,32,33,51,39,72,7,76,88,56,80,11,20}

    {77,62,75,24,16,55,82,48,58,60,41,73,98,29,57,95,67,26,35,9,6,15,78,45,37,100,42,28,25,21,17,47,69,79,53,31,61,83,59,43,2,40,18,70,90,74,5,94,87,68}

    Returns: 19

  60. {86,26,67,49,93,60,44,55,35,6,51,88,2,23,58,42,27,10,39,7,24,31,19,21,82,74,33,56,76,85,75,91,80,97,43,28,87,40,69,38,16,30,12,48,94,1,59,81,9,98}

    {37,65,32,84,61,8,17,29,41,13,66,54,15,52,45,70,14,11,57,36,20,64,62,99,73,68,95,71,92,83,25,96,46,22,5,77,72,90,89,18,50,4,63,34,3,53,100,79,47,78}

    Returns: 24

  61. {21,42,61,90,82,14,38,10,66,100,78,52,4,18,87,6,75,2,20,65,54,43,35,29,58,1,5,3,59,16,34,7,95,83,19,68,92,22,53,60,89,81,31,76,11,40,97,36,94,48}

    {86,69,57,64,70,93,51,24,96,23,56,13,84,49,46,77,79,32,9,28,55,27,72,25,85,98,33,91,44,99,62,74,39,45,80,17,71,37,47,88,12,50,63,41,67,30,8,73,26,15}

    Returns: 24

  62. {38,99,69,29,41,68,76,39,27,89,87,56,58,78,71,83,75,9,14,61,54,45,85,53,28,31,64,73,66,55,37,34,11,65,91,93,23,84,25,12,7,95,1,47,32,82,98,48,18,88}

    {44,97,46,51,24,33,63,10,35,8,86,90,49,74,20,4,67,2,43,62,94,79,22,36,100,96,72,50,30,42,3,80,16,52,19,92,60,81,6,77,5,57,15,13,17,59,26,40,70,21}

    Returns: 33

  63. {15,54,41,74,68,56,18,83,84,46,31,30,36,38,29,61,9,51,70,14,89,5,88,93,79,3,82,73,34,62,77,94,64,6,35,96,67,60,80,69,78,49,76,50,4,100,8,58,22,55}

    {92,63,32,2,90,24,75,99,28,95,7,65,1,57,47,44,10,66,97,12,25,40,91,20,98,27,72,23,39,71,45,16,59,33,37,85,52,17,26,11,19,48,86,43,13,53,42,87,81,21}

    Returns: 25

  64. {78,33,93,43,3,39,95,40,45,21,74,88,23,11,15,90,44,58,46,56,38,63,47,97,20,64,96,2,55,1,66,36,71,52,87,26,51,85,50,81,69,19,67,34,12,41,31,8,99,7}

    {42,100,68,24,89,57,62,32,70,91,83,60,75,13,65,59,16,28,4,9,73,14,80,10,53,37,35,94,27,54,17,84,77,30,86,25,49,48,76,92,22,72,79,82,5,98,29,6,61,18}

    Returns: 27

  65. {68,14,66,49,52,71,34,84,43,51,55,24,76,26,2,33,67,90,85,59,29,5,72,98,79,10,12,89,44,62,78,7,39,53,94,69,82,21,92,81,75,70,41,56,50,31,35,47,3,74}

    {13,40,93,64,97,60,18,42,46,20,58,4,8,83,38,25,61,30,54,23,88,87,37,57,9,15,91,27,19,100,95,80,77,6,28,65,17,63,32,11,96,48,73,22,45,86,16,1,36,99}

    Returns: 28

  66. {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50}

    {51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100}

    Returns: 0

  67. {3, 4 }

    {2, 1 }

    Returns: 2

  68. {2 }

    {1 }

    Returns: 1


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: