博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
April Fools Day Contest 2019: editorial回顾补题
阅读量:4971 次
发布时间:2019-06-12

本文共 2663 字,大约阅读时间需要 8 分钟。

A. Thanos Sort
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

 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.

Input

The first line of input contains a single number nn (1n161≤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 (1ai1001≤ai≤100) — the elements of the array.

Output

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.

Examples
input
Copy
41 2 2 4
output
Copy
4
input
Copy
811 12 1 2 13 14 3 4
output
Copy
2
input
Copy
47 6 5 4
output
Copy
1
Note

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
using namespace std;int a[100];int b[17],c[17],d[17];int ff(int x,int y){ int t=1,sum=1; for(int i=x+1;i<=y;i++){ if(a[i]>=a[i-1]) sum++; else{ t=0; } } if(t==1) return sum; else return max(ff(x,(x+y-1)/2),ff((x+y+1)/2,y));}int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } cout<
<
B. Kanban Numbers
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
 
Input

The input contains a single integer aa (1a991≤a≤99).

Output

Output "YES" or "NO".

Examples
input
 
5
output
 
YES
input
 
13
output
 
NO
input
 
24
output
 
NO
input
 
46
output
 
YES 这个就是脑洞题了,题目信息很少,kanban数就是把数字转化为英语, 然后含有k,n,a,b的为no 没有这些字母的是yes;真是脑洞大开
C. Mystery Circuit
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Input

The input contains a single integer aa (0a150≤a≤15).

Output

Output a single integer.

Example
input
 
3
output
 
13
 

转载于:https://www.cnblogs.com/yfr2zaz/p/10646145.html

你可能感兴趣的文章
寻找二叉查找树中比指定值小的所有节点中最大的那个节点
查看>>
如何设置输入框达到只读效果
查看>>
RT3070 USB WIFI 在连接socket编程过程中问题总结
查看>>
MIS外汇平台荣获“2013年全球最佳STP外汇交易商”
查看>>
LeetCode 题解之Add Digits
查看>>
hdu1502 , Regular Words, dp,高精度加法
查看>>
20120227_CET6
查看>>
SpringBoot在idea中的热部署配置
查看>>
MyEclipse连接SQL Server 2008数据库的操作方法
查看>>
leetcode【67】-Bulb Switcher
查看>>
JS验证图片格式和大小并预览
查看>>
laravel5.2 移植到新服务器上除了“/”路由 ,其它路由对应的页面显示报404错误(Object not found!)———新装的LAMP没有加载Rewrite模块...
查看>>
编写高质量代码--改善python程序的建议(六)
查看>>
windows xp 中的administrator帐户不在用户登录内怎么解决?
查看>>
接口和抽象类有什么区别
查看>>
Codeforces Round #206 (Div. 2)
查看>>
Mycat分表分库
查看>>
模板的文件名和方法名一定要一致!!
查看>>
**p
查看>>
优先队列详解
查看>>