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

×

CodeForces Tester giving wrong output

I just began giving competitions on codeforces . However when I coded one of the questions the judge show that for a particular test case my program was giving WA . When I reviewed that test case and ran it on ideone it gave the correct expected output . What could be the problem ?

Link to my code (with the specific test case) : https://ideone.com/64wFll

Link to the problem : http://codeforces.com/contest/991/problem/B

asked 24 Jun '18, 02:39

japoorv's gravatar image

5★japoorv
29592356
accept rate: 0%


You forget to initialize local variable total.

Some clang static analizer output:

B.cpp:42:60: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage
  for (int c(0);c < n;c++){int a;sd(a);arr.push_back(a);total+=a;}

Also in case of such undefined behavior issue this link could be useful.

link

answered 24 Jun '18, 04:38

avm_'s gravatar image

6★avm_
843
accept rate: 11%

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:

×655

question asked: 24 Jun '18, 02:39

question was seen: 101 times

last updated: 24 Jun '18, 04:38