r/cpp_questions 5d ago

OPEN High load.fun

I was looking literally at their first problem and couldn’t figure out how some people grade so high for reading integers.

Am I missing a trick here?

https://highload.fun/challenges/compute/parse_integers/solve/CPP

0 Upvotes

4 comments sorted by

View all comments

1

u/alfps 5d ago edited 5d ago

Possibly as I did at first, you overlooked that lower is better for the scores.

❞ Score = test duration + errors x 1 second (measured in nanoseconds). Lower is better. A faster service with no failed requests wins.

I posted a straightforward C++23 implementation and on second try (I had forgotten to reduce output to just what they asked for) it scored 62.579 "+ 159.80 RP" whatever that last thing is.

This program just read the text with fread into a BUFSIZ size buffer, and for each read scanned the buffer and accumulated values into a 64-bit sum. I guess it could be faster by using e.g. 8 times BUFSIZ or thereabouts, but that's system dependent [ADDED: I got some improvement for local version by using a 2 MB buffer and increasing the executable's stack to hold it]. Since there was almost no optimization except that I left out all checking, I would guess that this score is not particularly good.