Advertisement
Guest User

ZCO afternoon1

a guest
Nov 22nd, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. Zonal Computing Olympiad 2013, 10 Nov 2012
  2.  
  3.  
  4.  
  5. Problem 1: Chewing
  6.  
  7.  
  8. Hobbes has challenged Calvin to display his chewing skills and chew two different types of Chewing Magazine's Diabolic Jawlockers chewing gum at the same time. Being a generous sort of tiger, Hobbes allows Calvin to pick the two types of gum he will chew.
  9.  
  10. Each type of chewing gum has a hardness quotient, given by a non-negative integer. If Calvin chews two pieces of gum at the same time, the total hardness quotient is the sum of the individual hardness quotients of the two pieces of gum.
  11.  
  12. Calvin knows that he cannot chew any gum combination whose hardness quotient is K or more. He is given a list with the hardness quotient of each type of gum in the Diabolic Jawlockers collection. How many different pairs of chewing gum can Calvin choose from so that the total hardness quotient remains strictly below his hardness limit K?
  13.  
  14. For instance, suppose there are 7 types of chewing gum as follows:
  15.  
  16. Chewing gum type 1 2 3 4 5 6 7
  17. Hardness quotient 10 1 3 1 5 5 0
  18.  
  19. If Calvin's hardness limit is 4, there are 4 possible pairs he can choose: type 2 and 7 (1+0 < 4), type 3 and 7 (3+0 < 4), type 2 and 4 (1+1 < 4) and type 4 and 7 (1+0 < 4).
  20.  
  21.  
  22.  
  23.  
  24. Input format
  25. Line 1 : Two space separated integers N and K, where N is the number of different types of chewing gum and K is Calvin's hardness limit.
  26.  
  27. Line 2: N space separated non-negative integers, which are the hardness quotients of each of the N types of chewing gum.
  28.  
  29.  
  30.  
  31.  
  32. Output format
  33. The output consists of a single non-negative integer, the number of pairs of chewing gum with total hardness quotient strictly less than K.
  34.  
  35.  
  36.  
  37.  
  38. Sample Input
  39. 7 4
  40. 10 1 3 1 5 5 0
  41.  
  42.  
  43.  
  44.  
  45. Sample Output
  46. 4
  47.  
  48.  
  49.  
  50.  
  51. Test data
  52. In all subtasks, you may assume that all the hardness quotients as well as the hardness limit K are between 0 and 1,000,000, inclusive.
  53.  
  54. Subtask 1 (30 marks) : 2 ≤ N ≤ 2,000.
  55.  
  56. Subtask 2 (70 marks) : 2 ≤ N ≤ 100,000.
  57.  
  58.  
  59.  
  60.  
  61. Live evaluation data
  62. Subtask 1: Testcases 0,1,2,3.
  63.  
  64. Subtask 2: Testcases 4,5,6.
  65.  
  66.  
  67.  
  68.  
  69. Limits
  70. Time limit : 3s
  71.  
  72. Memory limit: 64 MB
  73.  
  74.  
  75.  
  76.  
  77. Note
  78. The answer might not fit in a variable of type int. We recommend that type long long be used for computing the answer. If you use printf and scanf, you can use%lld for long long.
  79.  
  80. CPU Timelimit: 3 seconds
  81. Memory limit: 64M
  82. Grading style: ioi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement