当前位置: 首页 > news >正文

7_12_2013 E: Hard problem

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

Problem E: Hard problem

Time Limit: 1 Sec   Memory Limit: 128 MB
Submit: 63   Solved: 21
[ Submit][ Status][ Web Board]

Description

The cat gets N mice from dreamone, and she can choose K mice from them as the order which is listed from 
left to right for dinner. But there is a limitation that the second mouse is no bigger than the first one, the third 
one is no bigger than the second one….the Kth one is no bigger than the (K-1) th one. Actually, there is always 
not a single method to choose the K mice from the N mice as the way described above; we can assume there 
is M ways. This time, the cat of dreamone’s has thought another hard problem:  
For each way, there is always a value for the Kth mouse. She wants to know the biggest value for the Kth 
mouse of all the M ways. Can you get it? Of course, not all of you have understood the idea, so there is an 
example blew: 
We can assume N=4, K=2. 
The N (N=4) numbers represented the N mice are given blew from left to right: 
4 6 5 4 
According to the rules above, we can get four ways for choosing K mice, such as: 
4 4;  6 5;  6 4;  5 4 
So the answer is 5.because the value 5 is the biggest one of the four ways for the Kth number.  
If the cat can not solve the problem as quickly as she can, she will feel very boring, so she turns to you, a 
topcoder of SWUST, for help. Can you help her? 

Input

The first line of input will be a positive integer indicating how many test cases will be included (T). Each of 
the next T cases will contain two parts: 
The first part: two integer N, K (1<=N<=10000, 1<=K<=10) 
The second part: N numbers (which is no larger than 1000000) represented the N mice from left to right. 

Output

For each test, you should output the biggest value for the Kth numbers of all the manners. If you can not find 
any way to choose the Kth mouse, just output “OH, NO” instead. 

Sample Input

2 4 2 4 6 5 4 4 2 1 2 3 4

Sample Output

5 OH,NO

#include <iostream>
#include <stdio.h>
using namespace std;

int
main()
{
    int tu, n, k;
    int s[11], num[10010];
    while(tu--){
        for(int i=0; i<=10; i++)
            s[i]=0;
        cin>>n>>k;
        cin>>s[0];
        s[0]=num[0];
        for(int i=1; i<n; i++){
            cin>>num[i];
            for(int j=0; j<=10; j++){
                if(num[j]>0){
                    if(num[i]<s[j]){
                        s[j]=num[i];
                    }
                    else{
                        s[j+1]=num[i];
                        break;
                    }
                }
            }
        }
        cout<<endl<<"****";
        for(int i=0; i<10; i++){
            cout<<s[i]<<" ";
        }
        cout<<endl;
        if(s[k]==0){
            cout<<"OH,NO"<<endl;
        }
        else{
            cout<<s[k]<<endl;
        }
    }
    return 0;
}


转载于:https://my.oschina.net/dianpaopao/blog/145705

相关文章:

  • shell编程——使用find和xargs
  • 微博mini for Windows Phone
  • hdu1242 Rescue(BFS +优先队列 or BFS )
  • java操作redis
  • 帧中继详解
  • hdu 1542 Atlantis
  • windows核心编程读后感(待续)
  • golang 基础
  • 毕业的第一个十年
  • 引领网页设计潮流的优秀网页作品赏析《第二季》
  • Inno Setup技巧[界面]自定义安装向导小图片宽度
  • HDU 4432 Sum of divisors (进制模拟)
  • HDU 4118 树形DP Holiday's Accommodation
  • Nginx HttpSubModule sub_filter模块的过滤功能
  • 快到极致的Android模拟器—Genymotion
  • 【Leetcode】104. 二叉树的最大深度
  • 【每日笔记】【Go学习笔记】2019-01-10 codis proxy处理流程
  • 【跃迁之路】【669天】程序员高效学习方法论探索系列(实验阶段426-2018.12.13)...
  • 30天自制操作系统-2
  • 4. 路由到控制器 - Laravel从零开始教程
  • CAP 一致性协议及应用解析
  • echarts的各种常用效果展示
  • Java读取Properties文件的六种方法
  • JS变量作用域
  • js正则,这点儿就够用了
  • magento 货币换算
  • MySQL的数据类型
  • Python连接Oracle
  • Terraform入门 - 1. 安装Terraform
  • 从零开始的webpack生活-0x009:FilesLoader装载文件
  • 前嗅ForeSpider采集配置界面介绍
  • 首页查询功能的一次实现过程
  • 数组的操作
  • 微信如何实现自动跳转到用其他浏览器打开指定页面下载APP
  • AI又要和人类“对打”,Deepmind宣布《星战Ⅱ》即将开始 ...
  • ​io --- 处理流的核心工具​
  • ​ubuntu下安装kvm虚拟机
  • #免费 苹果M系芯片Macbook电脑MacOS使用Bash脚本写入(读写)NTFS硬盘教程
  • #我与Java虚拟机的故事#连载10: 如何在阿里、腾讯、百度、及字节跳动等公司面试中脱颖而出...
  • $(function(){})与(function($){....})(jQuery)的区别
  • (06)金属布线——为半导体注入生命的连接
  • (31)对象的克隆
  • (HAL库版)freeRTOS移植STMF103
  • (poj1.2.1)1970(筛选法模拟)
  • (Redis使用系列) SpringBoot中Redis的RedisConfig 二
  • (翻译)Entity Framework技巧系列之七 - Tip 26 – 28
  • (附源码)小程序儿童艺术培训机构教育管理小程序 毕业设计 201740
  • (教学思路 C#之类三)方法参数类型(ref、out、parmas)
  • (南京观海微电子)——I3C协议介绍
  • ./configure、make、make install 命令
  • .360、.halo勒索病毒的最新威胁:如何恢复您的数据?
  • .FileZilla的使用和主动模式被动模式介绍
  • .net 8 发布了,试下微软最近强推的MAUI
  • .NET Core 将实体类转换为 SQL(ORM 映射)
  • .Net 知识杂记