CLEANUP WA. Help!

https://www.codechef.com/viewsolution/46545442
This is my code for CLEANUP Problem - CodeChef this.
Its passing sample cases but giving WA. Where did I go wrong?

Your solution has out-of-bounds accesses even with the sample testcase:

[simon@simon-laptop][17:03:14]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh 
Compiling sanketkittad-CLEANUP.cpp
+ g++ -std=c++17 sanketkittad-CLEANUP.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
+ set +x
Successful
[simon@simon-laptop][17:03:19]
[~/devel/hackerrank/otherpeoples]>echo "3
6 3
2 4 1
3 2
3 2
8 2
3 8" | ./a.out
sanketkittad-CLEANUP.cpp:16:43: runtime error: index 3 out of bounds for type 'int [*]'
sanketkittad-CLEANUP.cpp:18:11: runtime error: index 6 out of bounds for type 'int [*]'
sanketkittad-CLEANUP.cpp:24:37: runtime error: index 3 out of bounds for type 'int [*]'
3 21858 
5 
sanketkittad-CLEANUP.cpp:16:44: runtime error: index 3 out of bounds for type 'int [*]'
sanketkittad-CLEANUP.cpp:20:12: runtime error: index 1 out of bounds for type 'int [*]'
1 

1 4 6 
sanketkittad-CLEANUP.cpp:26:38: runtime error: index 6 out of bounds for type 'int [*]'
2 5 7 
1 Like

okay i’ll work on it thank you

1 Like