Hard problem
1022: Hard problem
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 43
Solved: 12
Description
Input
Output
Sample Input
Sample Output
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std;
#define MAX 10000
int line[MAX+10];
int num[11];
int dp[MAX+10][11];
int get_min(int a,int b)
{
return a>b?b:a;
}
int get_max(int a,int b)
{
return a>b?a:b;
}
int main()
{
//freopen("E.in","r",stdin);
//freopen("E1.out","w",stdout);
int n,m,t,i,j,flag,ans;
scanf("%d",&n);
while(n--)
{
flag=0;ans=0;
scanf("%d%d",&m,&t);
for(i=0;i<m;i++)
scanf("%d",&line[i]);
if(t>m)
printf("OH,NO\n");
else
{
memset(num,-1,sizeof(num));
memset(dp,-1,sizeof(dp));
num[0]=line[0];
for(i=0;i<m;i++)
{
dp[i][0]=line[i];
int temp=get_min(i,t);
for(j=temp;j>=1;j--)
{
if(num[j-1]==-1)
continue;
else if(num[j-1]>=line[i])
{
dp[i][j]=line[i];
num[j]=get_max(num[j],line[i]);
}
}
num[0]=get_max(num[0],line[i]);
}
for(i=t-1;i<m;i++)
{
if(dp[i][t-1]>ans)
{
ans=dp[i][t-1];
flag=1;
}
}
if(flag)
printf("%d\n",ans);
else
printf("OH,NO\n");
}
}
return 0;
}
FROM:暑假第三场
Hard problem的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- hbase+hive应用场景
一.Hive应用场景本文主要讲述使用 Hive 的实践,业务不是关键,简要介绍业务场景,本次的任务是对搜索日志数据进行统计分析.集团搜索刚上线不久,日志量并不大 .这些日志分布在 5 台前端机,按小时 ...
- 详解MySQL三项实用开发知识
其实项目应用的瓶颈还是在db端,在只有少量数据及极少并发的情况下,并不需要多少的技巧就可以得到我们想要的结果,但是当数据量达到一定量级的时 候,程序的每一个细节,数据库的设计都会影响到系统的性能.这里 ...
- [python]使用pexpect模块进行批量scp
#!/usr/bin/env python# -*- coding: utf-8 -*- #wangxiaofei #awcloud自动化测试 import time,osimport threadi ...
- javascript面向对象实例
非私有属性 function Student(name, gender, age, grade, teacher){ this.name = name; this.gender = gender; t ...
- 书签(Bookmarks)
工作台允许使用者在文件中创建书签,通过这些书签,使用者可以从书签视图里快速打开这些文件,并跳转到相应的行. (1)在编辑器左边灰色的区域里单击鼠标右键,在弹出的菜单里选择“Add Bookmark.. ...
- 无聊之作,RPGdemo制作(一)角色state模式
今天周末,在家无事可做,不知道为什么,突发奇想,想写一个RPG游戏的demo玩玩.所以就记录一下. 第一步要做的是,为以后的角色类写一个state模式的类,考虑到可能以后会用到,所以用模版来实现, / ...
- NET知识大纲
第一部分 C#编程基础 1.(30)变量.运算符(+.-.*./.++.--.括号.==.!=.>.<.>=.<=.&&.||).流程控制(if.while.f ...
- Leetcode: Length of Last Word in python
Length of Last Word Total Accepted: 47690 Total Submissions: 168587 Given a string s consists of ...
- [转]Javascript定义类的三种方法
作者: 阮一峰 原文地址:http://www.ruanyifeng.com/blog/2012/07/three_ways_to_define_a_javascript_class.html 将近2 ...
- Spark及其应用场景初探
最近老大让用Spark做一个ETL项目,搭建了一套只有三个结点Standalone模式的Spark集群做测试,基础数据量大概8000W左右.看了官方文档,Spark确实在Map-Reduce上提升了很 ...