http://acm.hdu.edu.cn/showproblem.php?pid=5701

给出一个序列,取其中的任何一个连续的序列,该序列的数从小到大排列,待更新,,,

 #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int MAXN = ;
int num[MAXN];
int arr[MAXN];
int sum[MAXN*];
int cnt[MAXN];
int main()
{
int n;
while(~scanf("%d",&n))
{
for(int i = ;i<=n;i++)
scanf("%d",&num[i]);
for(int i = ;i<=n;i++)
{
int temp = num[i];
memset(arr,,sizeof(arr));
memset(sum,,sizeof(sum));
int res = ;
for(int j = i-;j>=;j--)
{
arr[j] = arr[j+]+((num[j]>temp)?-:);
sum[arr[j]+n]++;
if(arr[j]==)
res++;
}
for(int j = i+;j<=n;j++)
{
arr[j] = arr[j-]+((num[j]>temp)?:-);
if(sum[arr[j]+n]>)
res=res+sum[arr[j]+n];
if(arr[j]==)
res++;
}
cnt[i] = res+;
}
printf("%d",cnt[]);
for(int i = ;i<=n;i++)
printf(" %d",cnt[i]);
printf("\n");
}
return ;
}

最新文章

  1. MVC代码中如何调用api接口
  2. myeclipse编译问题
  3. Aspose.Cells 首次使用,用到模版填充数据,合并单元格,换行
  4. Bringing up interface eth0: Error:Connection activation failed:Device not managed by NetworkManager
  5. 一个可能有用的封闭PGSQL操作的PYTHON函数
  6. Spring + iBatis 的多库横向切分简易解决思路
  7. ARM Cortex-M
  8. Ubuntu Server 14.04 LTS(64bit)已安装 weblogic Server 12c(12.1.3) Zip Distribution
  9. Array数组常用的5个方法
  10. 记录一次 “ORA-12516:TNS:监听程序找不到符合协议堆栈要求的可用处理程序” 的处理过程
  11. 单线程泵问题(com操作时间超过60s报错)
  12. shell 读取配置文件的方法
  13. python练习实例1--------给定数字组成三位数
  14. Scrum冲刺阶段1
  15. 【BZOJ1228】[SDOI2009]E&amp;D(博弈论)
  16. android侧滑删除,模仿qq跟进item显示删除按钮
  17. PRId64的正确用法
  18. centos安装eclise启动报错
  19. Pascal-S代码注释
  20. Buffer对象的总结

热门文章

  1. Struts2之ModelDriven的使用
  2. Windows磁盘MBR结构详解
  3. 10 个经典PHP函数
  4. php......房屋租赁练习
  5. python cookbook 数据结构
  6. 《程序员代码面试指南》第二章 链表问题 在单链表和双链表中删除倒数第K个节点
  7. Python 3 socket 编程
  8. tp导出excel
  9. ubantu16.04
  10. iOS App被拒原因以及解决方案总结。