You are not logged in. Please login at www.codechef.com to post your questions!

×

# include <stdio.h>

int main() { int t,i,j,a,avg,sum=0,count=0,tot=0; scanf("%d",&t); for(i=0;i<t;i++) {scanf("%d",&a[i]); sum=sum+a[i]; } avg=sum/3; for(i=0;i<t;i++) {if(a[i]==avg) count++; a[i]==0; } for(i=0;i<t;i++) { for(j=i;j<t;j++) { tot=tot+a[j]; if(tot==avg) {count++;}}} if(count==3) printf("Yes\n%d",avg); else printf("No\n"); return 0; }

//WHERE IS MY CODE WRONG??????

asked 21 Feb, 21:43 11
accept rate: 0%

Its very hard to read your code, use external code sharing sites or markup to share your code instead of directly copy pasting it.

Anyway refer to this link for TONYFOOD: https://www.geeksforgeeks.org/partition-set-k-subsets-equal-sum/ (set k = 3)

(21 Feb, 23:47)
1

Here is his well-indented code - https://ideone.com/63YoPy

(22 Feb, 21:46)
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

question asked: 21 Feb, 21:43

question was seen: 55 times

last updated: 22 Feb, 21:46