Don’t use maps use a frequency array instead
zephxr
June 29, 2020, 10:02am
3
Have You Tried unordered_map instead of map?
zephxr
June 29, 2020, 10:17am
5
I think array can work instead of map and once try printf scanf instead cin cout.
@zephxr No help either from scanf printf
@cubefreak777 If X=10^6 then side length can be 10^5 as 10^5 is factor of X. And if all array elements are 10^6 . Then sum would be 10^6*10^5=10^11. This value won’t fit in freq array.
You only have to consider sums that are less than X , so you can have a frequency array of size 1e6
1 Like
zephxr
June 29, 2020, 11:33am
9
Have you tried using array?
@zephxr @cubefreak777 Yes I tried
But why was any kind of map giving me TLE?
AC Submission 100 Points
1 Like
zephxr
June 29, 2020, 12:15pm
11
Map takes O(Logn) time in worst case
Unordered map takes O(1) time in best case and O(n) Time in Worst case
Array takes O(1) time in worst case.
1 Like