×

# TABLESUM WA

 1 Could someone please tell me what's going wrong with this TABLESUM code? I am getting WA in all except 3 test cases. The algorithm is O(N), so time is not an issue. asked 06 Jan '15, 17:37 2★sandy999 391●1●16●38 accept rate: 10% http://discuss.codechef.com/questions/60311/inoi-2012-problem-2-tablesum (10 Jan '15, 16:51) I already saw that thread, in fact my solution is same as the O(N) solution in the Stack Overflow link, but yet my code yields WA. Thanks anyway (10 Jan '15, 16:53) sandy9992★ YEAH SOMEBODY PLEASE RESPOND ... I'm also having the same problem ... http://cpp.sh/2jym ... THANKS IN ADVANCE!!! (28 Jan '15, 00:26) arpanb83★

#include<iostream>


# include<stdio.h>

using namespace std; int a[200005],n,large[200005],front[200005]; int main() { //freopen("question.txt","r",stdin); cin>>n; int i,j,k; for(i=0;i<n;i++)cin>>a[i]; large[n-1]=a[n-1]+1; for(i=n-2;i>=0;i--)large[i]=max(large[i+1]+1,a[i]+1); //for(i=0;i<n;i++)cout<<large[i]<<" ";cout<<endl; front[0]=a[0]+1; for(i=1;i<n;i++)front[i]=max(front[i-1],a[i]+i+1); //for(i=0;i<n;i++)cout<<front[i]<<" ";cout<<endl; cout<<front[n-1]<<" "; for(i=1;i<n;i++) { j=front[n-1-i]+i;j=max(j,large[n-i]); cout<<j<<" "; } }

1111
accept rate: 0%

 toggle preview community wiki:
Preview

By Email:

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:

×6

question asked: 06 Jan '15, 17:37

question was seen: 3,435 times

last updated: 28 Jan '15, 08:53