摘要: 题意很简单,在一串正整数序列中找一个连续的子序列使该序列和大于等于一个已知量S,但要求序列长度最短,通常喜欢暴力枚举这个题目跟大白书之前的一个题目很像,在数列A中 求 Ai-Aj最大 并且 i=S,则不断增加i,否则,就增加j。这样只是枚举了一下终点,而找到起点几乎是常数时间。#include #include #include using namespace std;int num[100010];int B[100010];int main(){ int n,s; while (scanf("%d%d",&n,&s)!=EOF) { for (int i 阅读全文
posted @ 2014-02-18 11:52 KRisen 阅读(260) 评论(0) 推荐(0) 编辑