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

×

TABLESUM WA

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.

https://www.dropbox.com/s/im7sjck0z8elukk/TABLESUM.cpp?dl=0

asked 06 Jan '15, 17:37

sandy999's gravatar image

3★sandy999
39111437
accept rate: 10%

edited 10 Jan '15, 13:24

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) sandy9993★

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<math.h>

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<<" "; } }

link

answered 28 Jan '15, 08:53

jayaganesh's gravatar image

3★jayaganesh
111
accept rate: 0%

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:

×6

question asked: 06 Jan '15, 17:37

question was seen: 687 times

last updated: 28 Jan '15, 08:53

Related questions