karishma_gupta's blog

By karishma_gupta, history, 4 years ago, In English

In this submission is there any logical error or precision error? I have been trying to tackle this issue for over an hour and still couldn't figure out the issue. The logic is not very complicated.

  • Vote: I like it
  • -12
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Just some little comments

1) search for fast I/O a sample here and you may encounter TLE for this question

2) try not to use float/double unless you really need it. For this question you need double when print the answer only, but not necessary in storing the values

»
4 years ago, # |
  Vote: I like it -23 Vote: I do not like it
  1. the sample i/o is using only 6 precision digits why are you using 17? see your first input the 4th line gives 1.33333333333333326 instead of 6 3's. I think this your main issue. the 10th test also says that thing- "wrong answer 103364th numbers differ — expected: '-1307.3528710', found: '-1307.3548723', error = '0.0000015'"

  2. use vectors instead of stack, it seems you are using too much memory

  3. think again before declaring double array and that too of size 200005.
  4. bits/stdc++ is not a good practice see the stackoverflow article for that. writing 10 headers wont cost you much time but including useless headers will
  • »
    »
    4 years ago, # ^ |
      Vote: I like it +10 Vote: I do not like it
    1. Not the case. As long as the difference of the answer and the output does not exceed 10^-6, it's fine, no matter how many digits there are. Here, the difference is 0.002, so if it prints only 6 digits or 8 digits, it will still be 0.002.

    2. There has been no MLE test cases yet. Also, I don't think there will be much difference between std::vector and std::stack.

    3. Maybe it could work fine. But, I recommend declaring the arrays globally all the time.

    4. It's not a good practice for programming for work. Otherwise, I don't see much difference between declaring bits/stdc++.h and a bunch of other headers, performance wise, just a few extra seconds of compiling (the compiler will know what the code needs, so it won't include unnecessary things in the actual program).

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      just a few extra seconds of compiling

      You can use precompiled headers to get rid of those extra seconds.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I do not understand your logic exactly but you do some strange things with this plus variable. For example, I wrote the following test case:

4
2 0
1 2 10
3
2 5

The last output is 2.5, which doesn't seem to be the average of 10 and 5.