应该是做麻烦了,一开始还没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. php的setcookie

    不同浏览器对cookie的原理不同,导致cookie的过期时间有些模糊. 经测试:火狐浏览器的cookie过期时间设置是根据增量原则.服务器端设置time()+num,或者time()-num,传递到 ...

  2. Linux下ps命令

    简述 Linux中的ps命令是Process Status的缩写.ps命令用来列出系统中当前运行的那些进程.ps命令列出的是当前那些进程的快照,就是执行ps命令的那个时刻的那些进程,动态的显示进程信息 ...

  3. org.hibernate.MappingException: duplicate import异常

    在开发hibernate时,一起多谢ORM类和映射文件时,报出:org.hibernate.MappingException: duplicate import com.XXX异常 解决方案: 检查你 ...

  4. suse10的网络配置(静态IP)

    感觉跟fedora的差别还是蛮大的, 主要是配置文件的不同, 尤其是默认路由, 多了一个单独的文件ifroute-xxx    suse10的网卡配置文件在/etc/sysconfig/network ...

  5. ubuntu切换root

    sudo passwd root这个命令是给root用户设定密码.然后su root切换到root用户.

  6. centos ssh 乱码

    vim /etc/sysconfig/i18n 然后把里面的LANG="zh_CN.UTF-8"改成LANG="zh_CN.GB18030"

  7. linux -- 串口调试总结

    linux 串口输出调试 在某些情况下,需要同时对两台或多台Linux主机进行管理和操作.如果手头缺少足够多的键盘和显示器,那么通过一台机器的串口对其余主机进行控制不失为一种快捷.有效的方法. 下面就 ...

  8. Cocoa Foundation框架学习笔记 - NSCalendar

    + (void)beginTest { /* FOUNDATION_EXPORT NSString * const NSGregorianCalendar; //公历(常用) FOUNDATION_E ...

  9. Drupal如何处理系统变量?

    Drupal的系统变量都保存在数据库variable表中: 然后,开发人员可以通过下面的API函数操作这些系统变量: function variable_get($name, $default = N ...

  10. INDEX_JOIN

    这里就以INDEX_JOIN为例,简单描述一下如何影响Oracle的执行计划的产生. 控制执行计划最简单的方法莫过于使用HINT,这篇文章要介绍的是,在不使用HINT的情况下,让Oracle产生IND ...