https://paste.ubuntu.com/p/mqwZPdFbTd/
Could that explain it?
try declaring the arrays globally ( before int main() ), i did this with your solution and now its wrong answer, not RE