Islands in the Data Stream UVALive
来源:互联网 发布:淘宝店铺营销中心 编辑:程序博客网 时间:2024/05/29 23:25
B - Islands in the Data Stream
水题:
题意:给出12个数字,如果一个子序列的两个端点及以内的每一个元素都大于子序列端点两边前一个和后一个数字,那么这个子序列称之为岛,求出这个序列一共有多少个岛。
思路:
利用三个for循环,把每个子序列都遍历一遍,令i,j为两个端点,用k进行遍历;
代码:
#include<cstdio>#include<iostream>#include<algorithm>using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { int w; int a[12]; scanf("%d",&w); for(int i=0; i<12; i++) { scanf("%d",&a[i]); } int sum=0; for(int i=0; i<12; i++) { for(int j=i; j<12; j++) { int faul=1; for(int k=i; k<=j; k++) { if(a[k]<=a[i-1]||a[k]<=a[j+1]) { faul=0; break; } } if(faul==1) { sum++; } } } printf("%d %d\n",w,sum); }}
这个题当时不会,没想到端点的事;
阅读全文
0 0
- Islands in the Data Stream UVALive
- UVALive 6465 Islands in the Data Stream 暴力模拟
- In-Stream Big Data Processing
- In-Stream Big Data Processing
- the Data Form in Silverlight
- meta-data in the Android
- 翻译-In-Stream Big Data Processing 流式大数据处理
- In-Stream Big Data Processing译文:流式大数据处理
- 翻译-In-Stream Big Data Processing 流式大数据处理
- it need flush out the previous h264 stream data
- Using XML Data Islands in Mozilla(Mozilla中使用XML数据岛)
- Islands and Bridges -- UVAlive 3267(状压DP)
- UVALive 4627 -- Islands (并查集)
- 数据岛(Data Islands)
- System.Data.SqlClient.SqlException: The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorr
- UVALive - 2728 A Spy in the Metro DP
- UVALive 5963 Confusion in the Problem Set 思维题、Interesting
- FFmpeg Only one stream supported in the RTP muxer
- Servlet中<url-pattern>匹配
- taskctl新增作业类型配置插件时注意事项
- vmvare12安装rehat6.4,并激活网卡
- css小图标
- vueJS的双向绑定原理
- Islands in the Data Stream UVALive
- MySQL ssl连接错误解决
- 使用 maven 构建模块化项目
- 嵌入式学习总体路线
- 51 Nod 1106 质数检测
- Android JobScheduler
- 模板:最大流最小割
- Linux strict_strtoul 函数
- #PL/SQL DEV连接Oracle 弹出空白提示框的解决方案#