nishanth.molleti9's blog

By nishanth.molleti9, history, 4 months ago, In English,

Below is my code to the problem named taxi . I will also attach the link of the problem . Let me know where does my code break. https://codeforces.com/problemset/problem/158/B

my code in C language :-

include<stdio.h>

main() { float c; int n, a[100],i ,sum=0 ,d,e=0,f=0; scanf("%d",&n); if(1<n<100000) {

for(i=0;i<n;i++)
    scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
    sum=sum+a[i];

}

// printf("%d\n",sum); c=sum/4; // printf("%f",c); d= fmod(sum,4); //printf("%d\n",d); if(d != 0) { e=c+1; printf("%d",e); } else if(d == 0) { f=c; printf("%d",f); } }

}

 
 
 
 
  • Vote: I like it
  • -16
  • Vote: I do not like it

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I will also attach the link of the problem

The codeforces community is so thankful to you

»
4 months ago, # |
  Vote: I like it +8 Vote: I do not like it

~~~~~

Your code here...

~~~~~

Can you add this next time when you plan to share your code? What you share is unreadable and I have to check your submission history.

About your solution: clearly the idea of your solution doesn't work as shown in the test case. For the case of 3 3 2, you cannot use 2 taxi as the first 2 groups will occupy 3 of 2 taxis, and the last group cannot fit in any of them as they are required to stay together.