Advertisement
nooobiiee

Untitled

Apr 14th, 2020
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,n,ck=0,count=0;
  6. double arr[5]={0};
  7. double sum=0;
  8.  
  9. cin >> t;
  10.  
  11. while(t--)
  12. {
  13. cin >> n;
  14. arr[n]++; /**ekhane oi array te koita 1 , koita 2,koita3 r koita 4 eta dekha hsse.. zemon 1
  15. input dile arr[1]++ hbe. orthat initially 0 thakle ekhn value hbe 1. then abr 1 input dile
  16. abar arr[1]++ hbe mane ekhn value hbe 2. temoni vbe 4 input dile arr[4]++ hbe. arr[4] er
  17. age ze man silo tar sathe 1 add hbe*/
  18. }
  19.  
  20.  
  21. count = min(arr[1],arr[3]); /**ei line diye 1 r 3 er koto gula jora somvob seta dekhano hsse.. zemon dhoro dewa ase {1 1 1 3 3 3 3
  22. 3 2 2 4 4}
  23. to amr uporer while loop e zeta korsi arr[n]++ seta onusare arr[1] = 3 and arr[3] = 5 hbe. ekhn tinta 1
  24. r 5 ta 3 niye koto gula jora hbe (1,3) jora? total 3 ta tai na? (1,3),(1,3),(1,3) karon zeta minimum
  25. ase sei songkhok jorai hbe. ar ami 1,3 jora ber korlam cause era thkle full ekta gari vorti hbe 4 joner.
  26. kono faka thkbena */
  27.  
  28.  
  29.  
  30.  
  31. arr[1] = arr[1] - count; /** ei dui line diye 3 r 1 jora howar baki koto gula 1 thke r koto gula 3 thke eita dekhe.. zemon uporer
  32. arr[3] = arr[3] - count; exmple e {1 1 1 3 3 3 3 3 2 2 4 4} e (1,3) jora hbe 3 ta. then 1 baki thkbe arr[1] - count,ekhane
  33. count holo total(1,3) jorar songkha. mane 3 - 3 = 0 . ei 0 arr[1] e store hbe.
  34. abar 3 baki thkbe arr[3] - count => mane 5 - 3 = 2 ta. orthat jora howar por 3 baki thkbe 2 ta.
  35. */
  36.  
  37.  
  38. count = count + arr[4] + arr[3]; /**to dekho amr ze baki 3 ase seglar jnno kintu alada garie lgbe.. coz amr hat e kono 1 nai.
  39. ze ami 3 er sthe dhukai dite parbo. and 4 er jnno same. 4 to pura gari niyei thkbe.. tar mddhe
  40. kaure dhukaite parbo na. ei jonno baki 3 r 4 joto gula ase sob gular jnno individual gari lgbe.
  41. oi jnno arr[4]+arr[3] liksi.. er sathe count o add korsi karon proti jora (1,3) er jnnow
  42. individual gari lgbe.. ei jnno ei line count+arr[3]+arr[4] mane 1,3,4 mile total koita gari lgbe*/
  43.  
  44.  
  45.  
  46. count = count + ceil((arr[1]+2*arr[2])/4.0); /**amra upore dekho 1,3,4 er jnno ber koresi . but 2 er jnno kori nai..
  47. ei jnno ekhane 2 er jnno ber korsi.. zemon 2 ta 2 er group mane 4 jon lok
  48. . ekhn 4 jon lok to ekta gari te uthte parbe. tai 4 diye vag korsi.
  49. assa ekhne arr[1] asse. karon dekho amra upore ze exmple nisi {1 1 1 3 3 3 3 3 2 2
  50. 4 4} ekhane (1,3) pair howar por. kono 1 baki silo na.
  51. but exmple zdi emn hto {1 1 1 1 3 3 4 2 2} tahole dekho pair howar por 2 ta 1 baki
  52. thkbe.. ekhn 2 ta 1 r 2 ta 2 niye koita bus lgbe seta hiseb korsi.
  53. zemon 2 ta 1 r 2 ta 2 mane total 6 jon lok . bus lgbe ceil(6/4) mane 2 ta. ei man
  54. ta ager total bus er sthe add kora hoise then*/
  55.  
  56. cout<<count;
  57. return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement