All of the Editorialist, Tester and Setter solutions give:
0
0
0
0
0
0
0
0
0
for the test input:
1
1 9
1
1 1 1 1 1 1 1 1 1
If printing out a single 0
gets AC, I guess the testcases must be pretty weak.
All of the Editorialist, Tester and Setter solutions give:
0
0
0
0
0
0
0
0
0
for the test input:
1
1 9
1
1 1 1 1 1 1 1 1 1
If printing out a single 0
gets AC, I guess the testcases must be pretty weak.
Can someone please explain why this code is giving Runtime Error?Itβs working fine for the given TC,but after submitting itβs giving Runtime Error RE (SIGSEGV).
Thank you!
[simon@simon-laptop][19:08:05]
[~/devel/hackerrank/otherpeoples]>./compile-latest-cpp.sh
Compiling cookieg13-CHARGES.cpp
+ g++ -std=c++14 cookieg13-CHARGES.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
cookieg13-CHARGES.cpp: In function βint main()β:
cookieg13-CHARGES.cpp:25:17: warning: unused variable βiβ [-Wunused-variable]
int N,K,i,TotalDist=0;
^
+ set +x
Successful
[simon@simon-laptop][19:08:14]
[~/devel/hackerrank/otherpeoples]>echo "1
3 3
010
2 1 3" | ./a.out
cookieg13-CHARGES.cpp:38:23: runtime error: index 2 out of bounds for type 'int [*]'
cookieg13-CHARGES.cpp:42:32: runtime error: index 2 out of bounds for type 'int [*]'
4
3
2