Can anyone help me solving this problem? CSES PROBLEMSET — Reading Books

Before contest

Codeforces Round #687 (Div. 1, based on Technocup 2021 Elimination Round 2)

14:00:34

Register now »

Codeforces Round #687 (Div. 1, based on Technocup 2021 Elimination Round 2)

14:00:34

Register now »

*has extra registration

Before contest

Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)

14:00:35

Register now »

Codeforces Round #687 (Div. 2, based on Technocup 2021 Elimination Round 2)

14:00:35

Register now »

*has extra registration

# | User | Rating |
---|---|---|

1 | tourist | 3687 |

2 | ecnerwala | 3600 |

3 | Benq | 3503 |

4 | ksun48 | 3421 |

5 | Um_nik | 3412 |

6 | Radewoosh | 3382 |

7 | maroonrk | 3323 |

8 | Itst | 3239 |

9 | apiadu | 3238 |

10 | ko_osaga | 3232 |

# | User | Contrib. |
---|---|---|

1 | Errichto | 205 |

2 | SecondThread | 199 |

3 | Monogon | 196 |

4 | vovuh | 190 |

5 | Um_nik | 186 |

6 | pikmike | 185 |

7 | antontrygubO_o | 184 |

8 | Ashishgup | 181 |

9 | pashka | 169 |

10 | Radewoosh | 167 |

Can anyone help me solving this problem? CSES PROBLEMSET — Reading Books

↑

↓

Codeforces (c) Copyright 2010-2020 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Nov/28/2020 20:04:26 (h2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

One hint: Look at the last book. If the last book is greater than the sum of all other books, what does this mean?

If the last book is greater that means the total time is the time of last book*2

Did you solve it fully? I am also struggling in this problem.Can you tell the approach?

But I couldn't figure out how to solve the rest of the part of the problem.

I was also solving this Problem.I am Getting WA in 3 test cases.

one of the test case is:

In my opinion answer should be 6000 but correct output given in the website is 5000.

Can anyone clarify why the answer is 5000 for this test case and not 6000

First person can read in order 1,2,3,4,5 and second in 2,3,4,5,1.

But this approach is not giving correct answer on each test case. Can you tell the correct approach for this

Here k will start reading book of 8 minutes while reading this j will read book of 2 and 3 minutes . So it will take 8 minutes as both are reading at the same time then this process will reversed . So it takes totak 8+8 = 16 minutes. Here largest number is greater than the summation of all other numbers so it takes largest number + largest number time.

Bro this much i know.But i am not able to solve ahead of it

Ok let's take a look at this 2 2 3 here k will start reading book of 2 minutes that time j will reading book of 3 minutes now after 2 minutes k will start reading another book of 2 minutes it will take him 4 minutes to read this 2 books now look at j it will take him 3 minutes to read that book then he will start reading book no 1 which have been finished by k .It will take j 5 minutes complete that.Now again look at k after 4 minutes k will start reading book of 3 minutes and he will complete all in 7 minutes at the same time j will also complete reading the book no 2 in 7 minutes.So actually it will take just 7 minutes in total.Sorry for my poor english ang long explanation.

Thanks for the explaination.

Can you make me understand a part of this github solution-Click Here

I didn’t understood when (m <= (s-m )) print s , i understood the rest of code but not getting why this line gets to AC.

There are 2 cases 1.If summation of all other values is lesser than the max value then the total time is 2*max value 2.If max value is not greater than summation of all other values then the total time is summation of all values. So here this line just checking the 2nd condition and printing s.

My Question was why that line works?Whats the reason for this.I know the meaning but don't know the reason behind it.

Actually i have taken this as an observation because we can see that for any case it works like my example 2 2 3. I didn't try to find any mathematical proof.

Can you explain in this test case how reading is taking place by both:

Order for k 1 2 3 4 5 6 9 8 7 10 and at the same time order for j 10 1 2 3 4 5 6 9 8 7

Bro According to your approach answer is 78 but the correct answer is 61. So,this is not the right way, i think

According to my approach the result is 61 because the answer is summation of all values.

According to your approach its coming to be- 16+2+3+4+5+6+9+9+8+16=78 Right?

No man there's may be some misunderstanding.I have explained that for 2 2 3 the answer is 7.It comes with summation of all the values , here it goes same for your last example i have said the index number of the books for both k and j.After sorting k will read from 1 to n and j will read n , 1 to n-1.Both will read simultaneously.So it takes the summation.

https://codeforces.com/blog/entry/79238?#comment-648392 check this out

I also struggle in the problem. Have youd found a hint?

Yeah, I struggled t00 . If n=3 and values are 2 2 3 think what will be total time? Btw , I have seen the solution , then got the point .

Is solution available before solving?

I found that in github.

https://codeforces.com/blog/entry/79238?#comment-648392 check this out

The min time is the maximum of reading alls books (sum of all books), and two times the longest book. Since the two children must read that longest book one after the other.

A visualization of the problem can be the books sorted by length. So one kid starts with the smallest, one with the longest. If there is no overlap of any book, then they can simply read all books. If there is overlap, then it is because the longest book is longer than the half of all books. And then ans is obviously the longest book times two.

I think you meant maximum

Yes, thanks, I changed it.