您当前的位置: 首页 > 

minato_yukina

暂无认证

  • 0浏览

    0关注

    138博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Subsequence UVALive - 2678

minato_yukina 发布时间:2022-03-21 16:47:42 ,浏览量:0

子序列. 给你一个数组a,长度为n,找一个连续最短的序列,使得和大于等于S. 思路:一眼双指针.因为双指针通常可以解决一些连续区间最小/最大的问题.在这题,数组a的元素都是正数的,所以总是能让右指针向右增加先构造出一个合法的区间[L,R],再尝试把L指针向左移动,使得答案最优,直到区间和不再是S.

/*
*/
#include
using namespace std;
typedef long long ll;
const int maxn = 3e5+2;
const int INF = 1e9+7;
typedef pair pii;
int main(){
//	freopen("1.txt","r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,S;
	while(cin>>n>>S){
		vector a(n+5,0);
		for(int i=1;i>a[i];
		}
		int L=1,R=1;int ans = INF;
		int sum=0;
		while(L            
关注
打赏
1663570241
查看更多评论
0.0394s