应该是做麻烦了,一开始还没A(幸好上一次比赛水惨了)

 #include<bits/stdc++.h>
#define lowbit(x) x&(-x)
#define LL long long
#define N 200005
#define M 1000005
#define mod 2147483648LL
#define inf 0x7ffffffff
using namespace std;
inline int ra()
{
int x=,f=; char ch=getchar();
while (ch<'' || ch>''){if (ch=='-') f=-; ch=getchar();}
while (ch>='' && ch<=''){x=x*+ch-''; ch=getchar();}
return x*f;
}
int a[];
struct node{
int x,y;
}ans[];
int cnt;
int main()
{
int n=ra(),start=;
bool flag=;
for (int i=; i<=n; i++)
{
int x=ra();
if (x!=) a[i]=x,flag=;
}
if (!flag)
{
cout<<"NO";
return ;
}
cout<<"YES"<<endl;
if (a[]==)
{
for (int i=; i<=n; i++)
if (a[i]!=)
{
for (int j=i+; j<=n; j++)
if (a[j]!= || j==n)
{
ans[++cnt].x=;
ans[cnt].y=j-;
start=j;
break;
}
break;
}
int last=start;
for (int i=last; i<=n; i++)
{
if (i==n && a[i]==)
ans[cnt].y=n;
if (a[i]!=)
{
ans[++cnt].x=start;
ans[cnt].y=i;
start=i+;
}
}
}
else
{
int last=start;
for (int i=last; i<=n; i++)
{
if (i==n && a[i]==)
ans[cnt].y=n;
if (a[i]!=)
{
ans[++cnt].x=start;
ans[cnt].y=i;
start=i+;
}
}
}
cout<<cnt<<endl;
for (int i=; i<=cnt; i++)
cout<<ans[i].x<<" "<<ans[i].y<<endl;
return ;
}

cf754 A. Lesha and array splitting的更多相关文章

  1. Codeforces 754A Lesha and array splitting(简单贪心)

    A. Lesha and array splitting time limit per test:2 seconds memory limit per test:256 megabytes input ...

  2. Codeforces 754A Lesha and array splitting (搜索)

    题目链接 Lesha and array splitting 设s[i][j]为序列i到j的和,当s[i][j]≠0时,即可从i跳到j+1.目标为从1跳到n+1,所以按照题意暴力即可. #includ ...

  3. 【codeforces 754A】Lesha and array splitting

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  4. Codeforces Round #390 (Div. 2) A. Lesha and array splitting

    http://codeforces.com/contest/754/problem/A 题意: 给出一串序列,现在要把这串序列分成多个序列,使得每一个序列的sum都不为0. 思路: 先统计一下不为0的 ...

  5. Educational Codeforces Round 69 (Rated for Div. 2) C. Array Splitting 水题

    C. Array Splitting You are given a sorted array

  6. CodeForces - 1175D Array Splitting(数组划分+后缀和+贪心)

    You are given an array a1,a2,…,ana1,a2,…,an and an integer kk. You are asked to divide this array in ...

  7. D. Array Splitting(后缀数组)

    You are given an array

  8. CF1175D Array Splitting

    题目链接 题意 给出一个长度为\(n\)的序列\(a\),要求分为恰好\(K\)段.第\(i\)个点的贡献是\(a_i \times f(i)\),\(f(x)\)表示x所属的是第几段. 思路 非常巧 ...

  9. Codeforce 1175 D. Array Splitting

    新鲜热乎的题 Codeforce 1175 D. 题意:给出一个长度为$n$的序列$a$,你需要把它划分为$k$段,每一个元素都需要刚好在其中一段中.分好之后,要计算$\sum_{i=1}^{n} ( ...

随机推荐

  1. activiti参考5-任务TASK

    一.概要 1,设计TASK的表主要是:ACT_RU_TASK,ACT_HI_TASKINST(见参考-activiti表): 2,任务主要有:人工任务(usertask),服务任务(serviceta ...

  2. 用KNN算法分类CIFAR-10图片数据

    KNN分类CIFAR-10,并且做Cross Validation,CIDAR-10数据库数据如下: knn.py : 主要的试验流程 from cs231n.data_utils import lo ...

  3. php时区测试

    php里面关于时间的函数有date,time,strtotime,gmdate等,里面只要和时间字符串相关的基本都收到时区的影响,所以时间戳才是唯一稳定时间记录,因为标准都是统一的.这里联想到数据库的 ...

  4. uploadify scriptData参数无法传参的问题

    最近需要使用到uploadify,需要向后台传递参数,使用script最多只能够传递一个参数,当然也可以通过合并参数然后再在服务器段拆分参数的方法来传递多个参数,而uploadify插件提供的scri ...

  5. hdu 4927 java求组合数(大数)

    import java.util.Scanner; import java.math.BigInteger; public class Main { private static int [] a = ...

  6. yii 操作session和cookie

    一,在Yii中使用session 1,CHttpSession 与原生态php5的session使用差别是,php5使用session_start();$_session['key'] = $valu ...

  7. Ubuntu 升级到13.10之后出现Apache2启动失败的问题

    昨天看到Ubuntu 13.04提示有新的发行版Ubuntu 13.10了,手痒了一下,没有忍住就升级了. 结果升级完毕之后发现Apache2服务启动失败了,失败信息是: Invalid comman ...

  8. SPF详解

    什么是SPF? 这里的SPF不是防晒指数,而是指Sender Policy Framework.翻译过来就是发信者策略架构,比较拗口,通常都直接称为SPF. SPF是跟DNS相关的一项技术,它的内容写 ...

  9. iframe根据子页面自动调整大小

    //iframe高度自适应 function IFrameReSize(iframename) { var pTar = document.getElementById(iframename); if ...

  10. 11个实用经典的SQL小贴士

    学习工作之余,在没有要解决问题的压力之下,还是建议系统的看看书,对于一些认为没啥用的知识点,也建议去仔细的看看,练练手,说不定什么时候就用到了,到时也好有针对性的去查,不至于盲目的按照自己的思路,重复 ...