I think:

给出k(4≤k≤5000)个互不相同的整数组成的序列Ni,判断是否存在4个整数Np、Nq、Nr和Ns(1≤p<q<r<s≤k),使得Nq>Ns>Np>Nr或者Nq<Ns<Np<Nr。

p   q    r     s

6   8    5    7   -- Nq>Ns>Np>Nr

7   5    8    6   -- Nq<Ns<Np<Nr

#include <stdio.h>
int main(void)
{
int n,t,i,numarr[10000],tem,j,k,flag;
while(scanf("%d",&n)!=EOF)
{
while(n--)
{
flag=0;
scanf("%d",&t);
for(i=0; i<t; i++)
{
scanf("%d",&numarr[i]);
} for(i=0; i<t; i++)
{
tem=numarr[i];
if(numarr[i+1]>tem)
{
for(j=i+2; j<t; j++)
{
if(numarr[j]<tem)
{
for(k=j+1; k<t; k++)
{
if(numarr[k]>tem&&numarr[k]<numarr[i+1])
flag=1;
}
}
}
}
if(flag==1)break;
}
for(i=0; i<t; i++)
{
if(flag==1)break;
tem=numarr[i];
if(numarr[i+1]<tem)
{
for(j=i+2; j<t; j++)
{
if(numarr[j]>tem)
{
for(k=j+1; k<t; k++)
{
if(numarr[k]<tem&&numarr[k]>numarr[i+1])
flag=1;
}
}
}
} }
if(flag)printf("YES\n");
else printf("NO\n");
}
}
return 0;
}

  

弱键(Weak Key, ACM/ICPC Seoul 2004, UVa1618)的更多相关文章

  1. [C++]环状序列(CircularSequence,ACM/ICPC Seoul 2004,UVa1584)

    Question 例题3-5 环状序列(CircularSequence,ACM/ICPC Seoul 2004,UVa1584) 长度为n的环状串有n种表示方法,分别为从某个位置开始顺时针得到,在这 ...

  2. 环状序列(Circular Sequence, ACM/ICPC Seoul 2004, UVa1584)

    长度为n的环状串有n种表示法,分别为从某 个位置开始顺时针得到.例如,图3-4的环状串 有10种表示: CGAGTCAGCT,GAGTCAGCTC,AGTCAGCTCG等. 在这些表示法中,字典序最小 ...

  3. [C++]最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583)

    Question 例题3-5 最小生成元 (Digit Generator, ACM/ICPC Seoul 2005, UVa1583) 如果x+x的各个数字之和得到y,就是说x是y的生成元.给出n( ...

  4. 分子量 (Molar Mass,ACM/ICPC Seoul 2005,UVa1586)

    习题 3-3 分子量 (Molar Mass,ACM/ICPC Seoul 2005,UVa1586) 给出一种物质的分子式(不带括号),求分子量.本题中的分子式只包含4种原子,分别为C,H,O,N, ...

  5. Irrelevant Elements, ACM/ICPC NEERC 2004, UVa1635

    这种题目最重要的是思路了清晰 #include <cstdio> #include <cstring> ;//sqrt(n)+1 is enough ][]; ]; int a ...

  6. 分子量 (Molar Mass,ACM/ICPC Seoul 2007,UVa 1586)

    解题思路: 1.将分子量用double 数组记录下来 2.将字符串存储在字符数组中,从头向后扫描,一直记住“字母”,对下一个字符进行判断,是否是数字,如果是数字:用一个整数记录,本代码中用的sum,同 ...

  7. 得分(Score,ACM/ICPC Seoul 2005,UVa 1585)

    #include<stdio.h> int main(void) { char b; int t,cou,sum; scanf("%d",&t); getcha ...

  8. 生成元(Digit Generator ,ACM/ICPC Seoul 2005 ,UVa 1583)

    生成元:如果 x 加上 x 各个数字之和得到y,则说x是y的生成元. n(1<=n<=100000),求最小生成元,无解输出0. 例如:n=216 , 解是:198 198+1+9+8=2 ...

  9. Circular Sequence,ACM/ICPC Seoul 2004,UVa 1584

    #include <stdio.h> #include <string.h> #define maxn 105 int lss(const char *s,int p,int ...

随机推荐

  1. ASP.NET Web API身份验证和授权

    英语原文地址:http://www.asp.net/web-api/overview/security/authentication-and-authorization-in-aspnet-web-a ...

  2. An Introduction to Interactive Programming in Python (Part 1) -- Week 2_1 练习

    # Practice Exercises for Functions # Solve each of the practice exercises below. # 1.Write a Python ...

  3. VS2010报错无法编译:LINK : fatal error LNK1123: failure during conversion to COFF: file invalid

    win7 64位 专业版 + vs2010 从vc6.0下转过来的一个项目,突然遇到这个问题. 解决方案: 用C:\Windows\winsxs\x86_netfx-cvtres_for_vc_and ...

  4. 慢牛股票-基于Sencha+Cordova的股票类APP

    13,14这两年,我的业余时间都花在了移动互联网技术和股票技术分析上,14年底,终于开发完成慢牛,上线小米应用商店.应用宝.百度应用商店.   慢牛是一款数据分析类的股票APP,提供数据订阅和数据分析 ...

  5. Orchard特性路线图(其实就是以后将做什么)

    本文链接:http://www.cnblogs.com/souther/p/4539975.html 主目录 近期,我们将注意力集中在完成第一版的发布并且计划开发下一版.特征路线图提及的就是项目涉及到 ...

  6. sql server 2008 数据库的完整性约束

    一.数据库完整性概述   1.数据库的完整性:   ①数据库的完整性是指数据的正确性和相容性 ②数据库完整性是防止不合语义或不正确的数据进入数据库 ③完整性体现了是否真实地反映现实世界   例:  学 ...

  7. 第十一课:js操作选择器的通用函数

    1.判断文档是否是XML文档 var isXML = function(elem){ var documentElement = elem && (elem.ownerDocument ...

  8. angular的splitter案例学习

    angular的splitter案例学习,都有注释了,作为自己的备忘. <!DOCTYPE html> <html ng-app="APP"> <he ...

  9. angular_$attrs

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  10. 在eclipse中安装插件

    1.在Eclipse中菜单help选项中选择install new software选项, 2.在work with 栏中输入 http://download.eclipse.org/releases ...