{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cstyle type\u003d\"text/css\"\u003e pre { text-align:left; font-family: \"Courier New\", Courier, monospace; font-size: 16px; white-space: pre; line-height:20px; text-indent: 0px; }\u003c/style\u003e\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003e海边躺着一排咸鱼,一些有梦想的咸鱼成功翻身(然而没有什么卵用),一些则是继续当咸鱼。一个善良的渔夫想要帮这些咸鱼翻身,但是渔夫比较懒,所以只会从某只咸鱼开始,往一个方向,一只只咸鱼翻过去,翻转若干只后就转身离去,深藏功与名。更准确地说,渔夫会选择一个区间[L,R],改变区间内所有咸鱼的状态,至少翻转一只咸鱼。\u003c/p\u003e\n \u003cp\u003e渔夫离开后想知道如果他采取最优策略,最多有多少只咸鱼成功翻身,但是咸鱼大概有十万条,所以这个问题就交给你了!\u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003e\u003c/p\u003e\n \u003cp\u003e包含多组测试数据。\u003c/p\u003e\n \u003cp\u003e每组测试数据的第一行为正整数n,表示咸鱼的数量。\u003c/p\u003e\n \u003cp\u003e第二行为长n的01串,0表示没有翻身,1表示成功翻身。\u003c/p\u003e\n \u003cp\u003e\u003c/p\u003e\n \u003cp\u003en≤100000\u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cdiv class\u003d\"pro_desc\"\u003e\n \u003cp\u003e在渔夫的操作后,成功翻身咸鱼(即1)的最大数量。\u003c/p\u003e\n\u003c/div\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e5\r\n1 0 0 1 0\r\n3\r\n0 1 0\r\n\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e4\r\n2\r\n\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\n \u003cp\u003e对于第一个样例,翻转区间[2,3],序列变为1 1 1 1 0。\u003c/p\u003e\n \u003cp\u003e对于第二个样例,翻转整个区间,序列变为1 0 1。 \u003c/p\u003e\n "}}]}