Why my code is giving wrong answer for subtask 1 even it is right

suppose you are given a test case β€œ1 0 0 0 0 1 0 0 0 0 1”. think about this.

line no 14:

for(long long i=0;i<n;i++);

you have a semicolon β€˜;’ there at last.

Remove that an your code should work for partial 50 points !!

Thanks bro. its giving right now for subtask 1st. I have given 1.30 hours yesterday and f :pensive: :unamused: :unamused: my self in the whole contest due to this i am unable to go on 3rd question for partial.

1 Like

PS: Always have a debugger installed maybe it could be VS Code or Clion or any other good software, it eases your debugging task .!

1 Like

Also, pay attention to compiler warnings!

Compiling akash_musky-ARRGAME.cpp
+ g++ -std=c++14 akash_musky-ARRGAME.cpp -O3 -g3 -Wall -Wextra -Wconversion -DONLINE_JUDGE -D_GLIBCXX_DEBUG -fsanitize=undefined -ftrapv
akash_musky-ARRGAME.cpp: In function β€˜int main()’:
akash_musky-ARRGAME.cpp:14:10: warning: this β€˜for’ clause does not guard... [-Wmisleading-indentation]
          for(long long i=0;i<n;i++);
akash_musky-ARRGAME.cpp:15:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the β€˜for’
akash_musky-ARRGAME.cpp:22:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
           for(long long i=0;i<v.size();i++)
+ set +x