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 ...
随机推荐
- 【转】Java 并发编程:线程间的协作(wait/notify/sleep/yield/join)
一.线程的状态 Java中线程中状态可分为五种:New(新建状态),Runnable(就绪状态),Running(运行状态),Blocked(阻塞状态),Dead(死亡状态). New:新建状态,当线 ...
- Goland软件使用教程(一)
Goland软件使用教程(一) Goland是由JetBrains公司旨在为go开发者提供的一个符合人体工程学的新的商业IDE.这个IDE整合了IntelliJ平台的有关go语言的编码辅助功 ...
- Linux 性能工具集
系统级别: 下面这些工具利用内核的计数器在系统软硬件的环境中检查系统级别的活动. vmstat: 虚拟内存和物理内存的统计,系统级别. mpstat: 每个CPU 的 使用情况. iostat: 每个 ...
- jstree获取半选中节点的方法
$('#jstree1').jstree().get_undetermined();返回一个数组,getPara();方法无法获取数组 get_undetermined ([full]) get a ...
- bzoj 3714: [PA2014]Kuglarz【最小生成树】
参考:https://blog.csdn.net/aarongzk/article/details/48883741 没想到吧.jpg 来自题解: "如果用sum[i]表示前i个杯子底球的总 ...
- (3)css文本样式
本篇学习资料主要讲解: 如何用css 的样式定义方法来介绍文字的使用. 第(1)节:用css设置文本样式. 一.弄懂文本文字的制作.利用css的样式定义版面 ...
- 超级实用的VSCode插件,帮你大幅提高工作效率
Visual Studio Code是一个轻量级但功能强大的源代码编辑器,可在桌面上运行,适用于Windows,macOS和Linux. 它内置了对JavaScript,TypeScript和Node ...
- iOS APNs远程推送流程精简版
1.去Apple Developer Center里创建应用的信息,指定APP ID(Bundle ID),配置里开启推送功能(Push Notifications). 后续步骤需要用到这个应用的包名 ...
- 简单的AndroidStudio单元测试工程配置
转载: http://www.jianshu.com/p/03118c11c199
- 配置yum源的步骤(阿里源)
配置yum源的步骤1.可以移除默认的yum仓库,也就是删除 /etc/yum.repos.d/底下所有的.repo文件(踢出国外的yum源) 1.配置yum源,找到阿里云的官方镜像源地址 https: ...