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 ...
随机推荐
- golang中获取字符串长度的几种方法
一.获取字符串长度的几种方法 - 使用 bytes.Count() 统计 - 使用 strings.Count() 统计 - 将字符串转换为 []rune 后调用 len 函数进行统计 ...
- 创建cordova项目
PhoneGap是一套能让你使用HTML5轻松调用本地API接口和发布应用到商店的应用开发平台.官方说有低成本,低开发周期,轻量化等优点,这些咱暂时也没法证明,略过不表.但是有一条跨平台,却是很明显的 ...
- 什么叫强类型的DATASET
强类型DataSet,是指需要预先定义对应表的各个字段的属性和取值方式的数据集.对于所有这些属性都需要从DataSet, DataTable, DataRow继承,生成相应的用户自定义类.强类型的一个 ...
- 风云流水 jQuery技巧总结 (转)
jQuery技巧总结 (转) 一.简介 1.1.概述 随着WEB2.0及ajax思想在互联网上的快速发展传播,陆续出现了一些优秀的Js框架,其中比较著名的有Prototype.YUI.jQuery.m ...
- 添加数据成功之后,通过true、false决定是否跳转
/** * 新增版本 * * @return */ public String AddVersionInfo() { // 快捷菜单 Integer code = Integer.parseInt(g ...
- gunicorn部署Flask服务
作为一个Python选手,工作中需要的一些服务接口一般会用Flask来开发. Flask非常容易上手,它自带的app.run(host="0.0.0.0", port=7001)用 ...
- session关联接口
#coding:utf-8 import requests,json,re ''' session关联接口,第一步访问登录接口,headers中要有cookie,不然会登录失败,登录成功后,添加随笔保 ...
- silverlight 4中datagrid列标题和列内容居中问题,增加自增长列
转载:http://www.cnblogs.com/guoyuanwei/archive/2011/01/02/1924163.html 命名空间:xmlns:Primitives="clr ...
- idea 设置项目编码
目前我了解的设置idea编码有两种形式(但深层次不太了解) 方式一: 这个方式需要你点击要设置编码单个文件,选择编码.一次只能修改一个文件编码 方式二: 一般工作时使用这个方式,文件编码,选择项目文件 ...
- bzoj 1499: [NOI2005]瑰丽华尔兹【dp+单调队列】
设f[a][i][j]为第a段时间结束时在(i,j)位置的最长滑行距离,转移很好想,就是分四个方向讨论,然后枚举这段时间的滑行长度取个max即可 但是这样是O(n^4)的,考虑优化 发现同一行或列,取 ...