Posts

Showing posts from 2020

Chef and Bored Games

Question :           Chef and Bored Games                            Problem Code:  PCJ18B

Download file

  Question :      Download file  (Codechef Problem)                        Problem Code:  DWNLD Solution in C++ : #include <iostream> using namespace std; int main() { int tc; //testcase cin>>tc; for(int j=0;j<tc;j++) {     int number,k,temp=0,net,price=0;     cin>>number>>k;     for(int i=0;i<number;i++)     {         int t,d;    //time and data         cin>>t>>d;         temp=temp+t;         if(temp>k)         {             net = temp-k;             if(net<t){                 price=net*d;             }             else                 price=price+(t*d);         }     }     cout<<price<<"\n"; } return 0; }  

Buying New Tablet

Question :      Buying New Tablet  (Codechef Problem) Solution in C++ :  #include <iostream> using namespace std; int main() { int testcase,k; cin>>testcase; for(k=0;k<testcase;k++) {     int number,budget,check=0,counter=0;     cin>>number>>budget;     for(int i=0;i<number;i++)     {         int width,height,price;         cin>>width>>height>>price;         if(price<=budget  && check<(width*height))         {             check = width*height;             counter++;         }     }     if(counter==0)     {         cout<<"no tablet\n";     }     else     {         cout<<check<<"\n";     } } return 0; }

Workers

Question :- https://www.codechef.com/problems/CHEFWORK  Solution in C++ language :- #include <iostream> using namespace std; int main() { // your code goes here int n,i; cin>>n; int c[n],t[n]; for(i=0;i<n;i++)     cin>>c[i];     for(i=0;i<n;i++)         cin>>t[i];     int a=100000,b=100000,d=100000;     for(i=0;i<n;i++){         if(t[i]==3){             if(c[i]<a)                 a=c[i];         }         else if(t[i]==2){             if(c[i]<b)                 b=c[i];         }         else if(t[i]==1){             if(c[i]<d)                 d=c[i];         }     }     if(a>b+d)         cout<<b+d;     else         cout<<a; return 0; }

Home

Image
Chef of Codechef help you to solve programming question of codechef. For HacherRank Problem solving doubt visit below given link :- https://hackofhackerrank.blogspot.com/2020/08/home.html For any doubts in codechef question you may write in this as a comment. Winner Winner Chicken Dinner   

Lost Weekends

Question :- https://www.codechef.com/problems/LOSTWKND Solution in C language :- #include <stdio.h> int main(void) { int t,i; scanf("%d",&t); int sum=0,a[5],p; for(i=0;i<t;i++){     sum=0;     for(int j=0;j<5;j++){         scanf("%d",&a[j]);         sum=sum+a[j];         }     scanf("%d",&p);         if(sum*p<=120)         printf("No\n");     else         printf("Yes\n"); } return 0; }

Days in Month

Question :- https://www.codechef.com/problems/NW1 Solution in C language :- #include <stdio.h> #include<string.h> int main(void) { // your code goes here int q,i; scanf("%d",&q); for(i=0;i<q;i++){     int temp , j , w , c=1 , a[7]={ };     char s[6]="\0";     scanf("%d",&w);     scanf("%s",s);     if(strcmp(s,"mon")==0){         temp=0;         a[0]=1;     }     else if(strcmp(s,"tues")==0){         a[1]=1;         temp=1;     }     else if(strcmp(s,"wed")==0){         a[2]=1;         temp=2;     }     else if(strcmp(s,"thurs")==0){         a[3]=1;         temp=3;     }     else if(strcmp(s,"fri")==0){         a[4]=1;         temp=4;     }     else if(strcmp(s,"sat")==0){         a[5]=1;         temp=5;     }     else if(strcmp(s,"sun")==0){         a[6]=1;         temp=6;