Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t,n,ck=0,count=0;
- double arr[5]={0};
- double sum=0;
- cin >> t;
- while(t--)
- {
- cin >> n;
- arr[n]++; /**ekhane oi array te koita 1 , koita 2,koita3 r koita 4 eta dekha hsse.. zemon 1
- input dile arr[1]++ hbe. orthat initially 0 thakle ekhn value hbe 1. then abr 1 input dile
- abar arr[1]++ hbe mane ekhn value hbe 2. temoni vbe 4 input dile arr[4]++ hbe. arr[4] er
- age ze man silo tar sathe 1 add hbe*/
- }
- 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
- 3 2 2 4 4}
- to amr uporer while loop e zeta korsi arr[n]++ seta onusare arr[1] = 3 and arr[3] = 5 hbe. ekhn tinta 1
- 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
- ase sei songkhok jorai hbe. ar ami 1,3 jora ber korlam cause era thkle full ekta gari vorti hbe 4 joner.
- kono faka thkbena */
- 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
- 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
- count holo total(1,3) jorar songkha. mane 3 - 3 = 0 . ei 0 arr[1] e store hbe.
- abar 3 baki thkbe arr[3] - count => mane 5 - 3 = 2 ta. orthat jora howar por 3 baki thkbe 2 ta.
- */
- 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.
- ze ami 3 er sthe dhukai dite parbo. and 4 er jnno same. 4 to pura gari niyei thkbe.. tar mddhe
- kaure dhukaite parbo na. ei jonno baki 3 r 4 joto gula ase sob gular jnno individual gari lgbe.
- oi jnno arr[4]+arr[3] liksi.. er sathe count o add korsi karon proti jora (1,3) er jnnow
- individual gari lgbe.. ei jnno ei line count+arr[3]+arr[4] mane 1,3,4 mile total koita gari lgbe*/
- 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..
- ei jnno ekhane 2 er jnno ber korsi.. zemon 2 ta 2 er group mane 4 jon lok
- . ekhn 4 jon lok to ekta gari te uthte parbe. tai 4 diye vag korsi.
- assa ekhne arr[1] asse. karon dekho amra upore ze exmple nisi {1 1 1 3 3 3 3 3 2 2
- 4 4} ekhane (1,3) pair howar por. kono 1 baki silo na.
- but exmple zdi emn hto {1 1 1 1 3 3 4 2 2} tahole dekho pair howar por 2 ta 1 baki
- thkbe.. ekhn 2 ta 1 r 2 ta 2 niye koita bus lgbe seta hiseb korsi.
- zemon 2 ta 1 r 2 ta 2 mane total 6 jon lok . bus lgbe ceil(6/4) mane 2 ta. ei man
- ta ager total bus er sthe add kora hoise then*/
- cout<<count;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement