Posts

Showing posts from June, 2020

CodeChef CHFICRM Solution

Problem  Link:  https://www.codechef.com/problems/CHFICRM Solution: #include <stdio.h> int main() {     int n,i,j,k,a,b,c,dec;     scanf("%d", &n);     for(i=0;i<n;i++){         a=0,b=0,c=0,dec=0;         scanf("%d", &j);         int x[j];         for(k=0;k<j;k++){             scanf("%d", &x[k]);             if(x[k]==5){                 a++;             }             else if(x[k]==10){                 b++;                 a--;             }             else{                 c++;                 if(b>0)b--;                 else a-=2;             }             if(a<0 || b<0|| c<0) dec=1;         }         if(dec==1)printf("NO\n");         else printf("YES\n");     }     return 0; } Solution with notes: #include <stdio.h> int main() {     int n,i,j,k,a,b,c,dec;     scanf("%d", &n);          //Number of test cases=n.     for(i=0;i<n;i++){         a=0,b=0,c=0,dec=0;    //Number of Rs