Getting Wrong answer using maps on same logic and getting accepted solution using vectors in C++

Revision en4, by aditraj2004, 2023-09-17 02:50:18

I was solving the problem https://codeforces.com/contest/1814/problem/C using C++ maps was getting wrong answer on Codeforces submission , was getting the correct answer by compiling and running the same code on the sublime text. I tried Custom Invocation , still was getting wrong answer . I solved the same problem with the same logic using vectors of pair and pair and got accepted solution . I am unable to understand why the solution using maps failed. Problem Link :- https://codeforces.com/contest/1814/problem/C` Submitted Solution using Maps in C++ :- https://codeforces.com/contest/1814/submission/223668739 Accepted Solution using vector : https://codeforces.com/contest/1814/submission/223672537

I thought the issue is happening when the map has only one element , so i tried to cover the case when the map has only one element separately , but still got the same error. The code is failing on this test case :-

n = 5 , s1 = 1 , s2 = 1 value of the array :- 1 1 1 1 1

Forgive me , if i have not expressed my views clearly or haven't explained the question properly because i am new to writting on codeforces

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English aditraj2004 2023-09-17 02:50:18 979
en3 English aditraj2004 2023-09-17 02:48:19 0 (published)
en2 English aditraj2004 2023-09-17 02:47:46 45 (saved to drafts)
en1 English aditraj2004 2023-09-17 02:44:23 1953 Initial revision (published)