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

×

WRONG ANSWER :TONYFOOD ,PLEASE GUIDE

include <stdio.h>

int main() { int t,i,j,a[100],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

bhats_511's gravatar image

1★bhats_511
11
accept rate: 0%

edited 21 Feb, 21:49

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) thesmartguy4★
1

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

(22 Feb, 21:46) akashbhalotia5★
toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×25
×4
×4

question asked: 21 Feb, 21:43

question was seen: 55 times

last updated: 22 Feb, 21:46