A. Thanos Sort
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

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
4
1 2 2 4
output

Copy
4
input

Copy
8
11 12 1 2 13 14 3 4
output

Copy
2
input

Copy
4
7 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<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 ;
}
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 (1≤a≤991≤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 (0≤a≤150≤a≤15).

Output

Output a single integer.

Example
input

 
3
output

 
13

April Fools Day Contest 2019: editorial回顾补题的更多相关文章

  1. 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 ...

  2. April Fools Day Contest 2014

    April Fools Day Contest 2014 A.C.H三道题目 ============================================================= ...

  3. 坑爹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 ...

  4. 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 ...

  5. April Fools Day Contest 2016 D. Rosetta Problem

    D. Rosetta Problem 题目连接: http://www.codeforces.com/contest/656/problem/D Description ++++++++[>+& ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. April Fools Day Contest 2016 C. Without Text 信号与系统

    C. Without Text 题目连接: http://www.codeforces.com/contest/656/problem/C Description You can preview th ...

随机推荐

  1. codeforces 688D D. Remainders Game(中国剩余定理)

    题目链接: D. Remainders Game time limit per test 1 second memory limit per test 256 megabytes input stan ...

  2. bzoj 4521 电话号码

    题目大意: 求$[L,R]$中,满足不同时存在4和8且有连续三个一样的个数 思路: 我为什么要记忆化搜索里带-1啊 我可真是个** 直接记忆化搜索记前两位是否有4,8以及是否满足连续 #include ...

  3. baiduTemplate 基本知识总结

    html <div id="tem1"></div> <div id="tem2"></div> <!-- ...

  4. Ubuntu 12.04 root默认密码? 如何使用root登录? (转载)

    转自:http://www.lupaworld.com/article-219280-1.html 在安装Ubuntu 12.04时并没有设置root的密码,登录的时候也没有使用root账户.当我们使 ...

  5. P3308 [SDOI2014]LIS(最小割+退流)

    传送门 设\(f[i]\)为以\(i\)结尾的最长上升子序列.可以考虑建这样一张图,对于所有的\(i<j,f[j]=f[i+1]\)连边\((i,j)\),\(f[i]=1\)的话连边\((S, ...

  6. mysql 状态查询

    select  COUNT(case when info.State = '0' then State end  ) as daichuliCount, COUNT(case when info.St ...

  7. Python实现判断回文串

    回文数的概念:即是给定一个数,这个数顺读和逆读都是一样的.例如:121,1221,a,aa是回文数,123,1231不是回文数.  while 1: String = input('请先输入一个字符串 ...

  8. [Usaco2017 Feb]Why Did the Cow Cross the Road II (Gold)

    Description 上下有两个长度为n.位置对应的序列A.B, 其中数的范围均为1~n.若abs(A[i]-B[j])<= 4,则A[i]与B[j]间可以连一条边. 现要求在边与边不相交的情 ...

  9. bryce1010的图像处理课程设计

    一.要求 完成课程教学中的大部分图像处理功能 二.平台 Qt c++ windows或者linux下 三.思路收集 1.QPixmap类 (一)QPixmap和QImage的区别 QPixmap是专门 ...

  10. JDBC中Oracle的SID和ServiceName两种方式的连接字符串格式

    SID格式: jdbc:oracle:thin:@<host>:<port>:<SID> 如: jdbc:oracle:thin:@192.168.1.1:1521 ...