F. 2023DLOI 小甲 第六题 双向删除(2.2)

    Type: Default 1000ms 128MiB

2023DLOI 小甲 第六题 双向删除(2.2)

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

说明

有n个数,保存在数组a[1...n],每个数都是0或者1,每次操作可以删除数组第一个数或者删除数组最后一个数,

问至少多少次操作之后,使得数组剩下的数的和等于S。如果不能完成任务,输出-1。

输入格式

第一行,两个整数,n和S 1<=n<=100000 1<=S<=100000。

第二行,n个整数,第i个整数是a[i],  a[i]是0或者1。第一行,两个整数,n和S 1<=n<=100000 1<=S<=100000。

第二行,n个整数,第i个整数是a[i],  a[i]是0或者1。

输出格式



一个整数。

16 2
1 1 0 0 1 0 0 1 1 0 0 0 0 0 1 1
7

提示

【提示】

40%的数据, n<=100

来源

指针移动

2023年大沥镇赛

Not Attended
Status
Done
Rule
ACM/ICPC
Problem
6
Start at
2025-12-16 12:15
End at
2025-12-24 20:15
Duration
200 hour(s)
Host
Partic.
29