April Fools Day Contest 2019: editorial回顾补题
1 second
256 megabytes
standard input
standard output
Thanos sort is a supervillain sorting algorithm, which works as follows: if the array is not sorted,
snap your fingers* to remove the first or the second half of the items, and repeat the process.
Given an input array, what is the size of the longest sorted array you can obtain from it using Thanos sort?
*Infinity Gauntlet required.
The first line of input contains a single number nn (1≤n≤161≤n≤16) — the size of the array. nn is guaranteed to be a power of 2.
The second line of input contains nn space-separated integers aiai (1≤ai≤1001≤ai≤100) — the elements of the array.
Return the maximal length of a sorted array you can obtain using Thanos sort
. The elements of the array have to be sorted in non-decreasing order.
4
1 2 2 4
4
8
11 12 1 2 13 14 3 4
2
4
7 6 5 4
1
In the first example the array is already sorted, so no finger snaps are required.
In the second example the array actually has a subarray of 4 sorted elements, but you can not remove elements
from different sides of the array in one finger snap. Each time you have to remove either the whole first half or th
whole second half, so you'll have to snap your fingers twice to get to a 2-element sorted array.
In the third example the array is sorted in decreasing order, so you can only save one element from the ultimate destruction.
思路:可以用递归先判断是不是排好了,如果没有,那么再看前半段或者后半段
返回最大值即可
#include<iostream>
using namespace std;
int a[];
int b[],c[],d[];
int ff(int x,int y){
int t=,sum=;
for(int i=x+;i<=y;i++){
if(a[i]>=a[i-])
sum++;
else{
t=;
}
}
if(t==)
return sum;
else
return max(ff(x,(x+y-)/),ff((x+y+)/,y));
}
int main(){
int n;
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i];
}
cout<<ff(,n)<<endl;
return ;
}
1 second
256 megabytes
standard input
standard output
The input contains a single integer aa (1≤a≤991≤a≤99).
Output "YES" or "NO".
5
YES
13
NO
24
NO
46
YES
这个就是脑洞题了,题目信息很少,kanban数就是把数字转化为英语,
然后含有k,n,a,b的为no
没有这些字母的是yes;真是脑洞大开
1 second
256 megabytes
standard input
standard output
The input contains a single integer aa (0≤a≤150≤a≤15).
Output a single integer.
3
13
April Fools Day Contest 2019: editorial回顾补题的更多相关文章
- April Fools Day Contest 2019 A. Thanos Sort
A. Thanos Sort time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- April Fools Day Contest 2014
April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...
- 坑爹CF April Fools Day Contest题解
H - A + B Strikes Back A + B is often used as an example of the easiest problem possible to show som ...
- April Fools Day Contest 2014 H. A + B Strikes Back
H. A + B Strikes Back time limit per test 1 second memory limit per test 256 megabytes input standar ...
- April Fools Day Contest 2016 D. Rosetta Problem
D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...
- April Fools Day Contest 2016 G. You're a Professional
G. You're a Professional 题目连接: http://www.codeforces.com/contest/656/problem/G Description A simple ...
- April Fools Day Contest 2016 F. Ace It!
F. Ace It! 题目连接: http://www.codeforces.com/contest/656/problem/F Description Input The only line of ...
- April Fools Day Contest 2016 E. Out of Controls
E. Out of Controls 题目连接: http://www.codeforces.com/contest/656/problem/E Description You are given a ...
- April Fools Day Contest 2016 C. Without Text 信号与系统
C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...
随机推荐
- 风云流水 jQuery技巧总结 (转)
jQuery技巧总结 (转) 一.简介 1.1.概述 随着WEB2.0及ajax思想在互联网上的快速发展传播,陆续出现了一些优秀的Js框架,其中比较著名的有Prototype.YUI.jQuery.m ...
- redhat输入用户名密码后又跳回到登录
一.如果忘记密码,可以进入single模式修改密码: 1.进入linux启动界面之后按e进入如下界面 2.按选择kernel /vmlinuz-2.4.20-8 ro root=LABEL=/ 项,按 ...
- bootstrap复选框和单选按钮
复选框和单选按钮标签包含在<Label>标签中<div class="checkbox"> <label><input type=&quo ...
- 关于jenkins的安装及自动部署
1. 安装Jenkins 1.1 准备Linux服务器, 关闭防火墙禁止开机启动 systemctl stop firewalld.service #停止firewall systemctl disa ...
- WordPress xmlrpc.php flaw exploited to install a WSO 2.1 Web Shell by oRb
WordPress xmlrpc.php flaw exploited to install a “WSO 2.1 Web Shell by oRb” Below you can see in the ...
- AWS EC2中部署Apache服务器(LAMP)
关键词: 1.新建aws ec2实例 2.使用putty连接到aws ec2 实例(SSH协议) 3.使用filezilla连接到aws ec2实例(SFTP协议) 4.在aws ec2上部署apac ...
- Activiti6.0教程 Eclipse安装Activiti Diagram插件(一)
最近这段时间打算出一个Activiti6.0的详细教程,Activiti作为一个流行的开源工作流引擎,正在不断发展,其6.0版本以API形式提供服务,而之前版本基本都是要求我们的应用以JDK方式与其交 ...
- Ubuntu 18.04 LTS 系统设置打不开了
在更换软件源后,安装了vim 和chrome,chrome很顺利,但是安装vim的时候后就显示有问题了,有的依赖版本不对,嫌版本太高,卸载后再装可以. 安装了python和python2 依旧是有些依 ...
- VS 2017 产品密钥
Visual Studio 2017(VS2017) 企业版 Enterprise 注册码:NJVYC-BMHX2-G77MM-4XJMR-6Q8QFVisual Studio 2017(VS2017 ...
- Jumping Jack CodeForces - 11B
Jumping Jack CodeForces - 11B 就是一个贪心. 基本思路: 正负没有关系,先取绝对值. 首先跳过头,然后考虑怎么回来. 设超过头的步数为kk.如果kk为偶数,那么直接在前面 ...