Maximise the value [Player Potential] (Hack with infy 2020 (ended ) )

Time limit is 5 second so can we apply bruteforce?

No . … . . .

Wont you need 8 bits ? 2 for each…?

i went for brute force since time limit is 5 seconds
i.e n*(n-1)/2
i.e 10^5*(10^5-1)/2
-> 5x10^4x10^5 => 5x10^9
if we consider 10^9 computations per second 5*10^9
i think it atleast give 50% of marks
but there must be better way
lets hope for the best

No brute force will not work in any of the case bro :slight_smile:

I think it at least gives 50% of marks for sure

Let 's see… :slight_smile:

bro will they hire system specialist role this year

will they hire system specialist role this year

They hire only PP (power pogrammer from Hack with infy) …only top 100 candidates onsite hackathon + interview

they don’t hire system specialist role like last year of (top 3000) people?
how do you know bro ?

On their website , , , , go and read over there :slight_smile:

bro if you don’t mind please give the link
thanks in advance!

Don’t worry they hired for SES role . And now about your bruteforce solution . Definately it will fetch some of points like you will get at least more than half i think. As N constraints is 100000 so in worst case we need comparison is (10^5 + 10^5-1 + 10^5-2…+1) = (10^5 * (10^5+1))/2 which is nearly equal to 510^9 and our system gives time limit is 5 second so we can assume that we can iterate nearly 510^9 . So I think brute force will give definitely some points . It may fail on strictly bounded data on 10^5.
@ssrivastava990
@ssjgz

@galencolin Please correct me if i’m wrong

Well, naively, each of the 5 \cdot 10^9 “operations” cause four function calls, which is not exactly ideal in terms of speed

NO this will not call any function . We can just calculate in O(1) in each iteration by using abs

Yes, but abs is a function and may not be inlined by the compiler, so you’re doing 2 \cdot 10^{10} subtractions plus abs operations, right?

1 Like

But any way what you think most of test case can pass this approach ?

From experience, probably not, but I don’t really know how compilers work

1 Like

Yes this might the case , so can i say 80% will get AC while in 20% due to more loop of abs calling will get TLE