Skip to content

[Pre-contest] Exercise B in Bash#23

Open
PJK136 wants to merge 1 commit intoINSAlgo:masterfrom
PJK136:precontest-ex_b
Open

[Pre-contest] Exercise B in Bash#23
PJK136 wants to merge 1 commit intoINSAlgo:masterfrom
PJK136:precontest-ex_b

Conversation

@PJK136
Copy link
Copy Markdown
Contributor

@PJK136 PJK136 commented Oct 27, 2018

I think the solution is too slow because of bash...
But the complexity seems fine.
Do you have an idea about how to optimize the code ?

@Nyrio
Copy link
Copy Markdown
Member

Nyrio commented Oct 27, 2018

The complexity is correct.
But Bash variables are only character strings, which are interpreted as numbers when using arithmetic operators. Therefore you can expect arithmetic operations to be very slow.

Do you want to try and optimize it more or is there no point in trying to optimize that? Also, since Polygon doesn't have support for bash scripts I didn't run benchmarks on your code, how much time does it take in the worst case among our test set?

@PJK136
Copy link
Copy Markdown
Contributor Author

PJK136 commented Oct 27, 2018

The worst case (input9.txt) took about 5,3 s on my computer. I already tried to optimize it but since I don't know Bash very well, I'm surely missing things, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants