Before contest

Codeforces Round 940 (Div. 2) and CodeCraft-23

20:47:57

Register now »

Codeforces Round 940 (Div. 2) and CodeCraft-23

20:47:57

Register now »

*has extra registration

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

1 | ecnerwala | 3648 |

2 | Benq | 3580 |

3 | orzdevinwang | 3570 |

4 | cnnfls_csy | 3569 |

5 | Geothermal | 3568 |

6 | tourist | 3565 |

7 | maroonrk | 3530 |

8 | Radewoosh | 3520 |

9 | Um_nik | 3481 |

10 | jiangly | 3467 |

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

1 | maomao90 | 174 |

2 | awoo | 164 |

3 | adamant | 163 |

4 | TheScrasse | 159 |

4 | nor | 159 |

6 | maroonrk | 156 |

7 | -is-this-fft- | 150 |

8 | SecondThread | 147 |

9 | orz | 146 |

10 | pajenegod | 145 |

↑

↓

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/20/2024 20:47:04 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

Instead of calculating min 1’s and min 2’s required for each subarray . Calculate min 1’s and 2’s required for whole array then compare the subarray sum with min sum

My submission : 248010905

There is a flaw in your logic. Consider 8 1 1 1 1 1 1 1 1, according to your logic, the corresponding array should have atleast a sum of 14 to make this one good. The correct answer is however 17.

The condition sum>=req in code is a necessary condition but not sufficient. The distribution of this sum matters consider the example 1,1,2,2 works fine with the logic but if we have 1,1,1,3 here though it has the same sum as before but the distribution of this sum is different, each of the ones must be incremented by atleast 1 so we need -3 from some element to maintain constant sum as per question but last element can't give 3 as it will become 0 after that.