codeforce B. Creating the Contest

http://codeforces.com/contest/1029/problem/B

水题真快乐= =

 1 public class Main {
 2     public static void main(String[] args) {
 3         Scanner io = new Scanner(System.in);
 4         long n = io.nextInt() - 1, a = io.nextInt(), b, len = 1, ans = 1;
 5         for (int i = 1; i <= n; i++) {
 6             b = io.nextInt();
 7             if (i == n) {
 8                 if (a * 2 >= b) len++;
 9                 ans = Math.max(ans, len);
10                 break;
11             } else if (a * 2 < b) {
12                 ans = Math.max(ans, len);
13                 len = 0;
14             }
15             len++;
16             a = b;
17         }
18         System.out.println(ans);
19     }
20 }

原文地址:https://www.cnblogs.com/towerbird/p/11711046.html

时间: 2024-11-09 16:20:26

codeforce B. Creating the Contest的相关文章

codeforce1029B B. Creating the Contest(简单dp,简单版单调栈)

B. Creating the Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a problemset consisting of nn problems. The difficulty of the ii-th problem is aiai. It is guaranteed t

CodeForces B. Creating the Contest

http://codeforces.com/contest/1029/problem/B You are given a problemset consisting of nn problems. The difficulty of the ii-th problem is aiai. It is guaranteed that all difficulties are distinct and are given in the increasing order. You have to ass

【贪心/DP/单调队列】【CF1029B】Creating the Contest

Description 给你一个单调不下降的长度为n的序列,请你找出一个最长的子序列,满足找出的子序列中,\(A_i<=A_{i-1}~\times~2\),其中i为下标,A为找出的子序列.对于一个长度为\(p\)的子序列,\(i~\in~[1,p-1]\). Input 两行,第一行是原序列的长度\(n\) 第二行是\(n\)个数,代表原序列中的\(n\)个数. Output 一行一个数,代表最长的长度 Sample Input 10 1 2 5 6 7 10 21 23 24 49 Samp

B. Creating the Contest(水题)

直接水过 #include<iostream> #include<algorithm> using namespace std; const int maxn=2e5+10; int a[maxn]; int n, u,maxx; int main(){ cin>>n; u=1; for(int i=0;i<n;++i)cin>>a[i]; for(int i=0;i<n-1;++i){ if(a[i]*2>=a[i+1]){ ++u; }

Codeforces Round #506 (Div. 3) A-C

CF比赛题解(简单题) 简单题是指自己在比赛期间做出来了 A. Many Equal Substrings 题意 给个字符串t,构造一个字符串s,使得s中t出现k次;s的长度最短 如t="cat",k=3, minlen(s)=9,s=catcatcat 1<=len(t),k<=50 题解 稍加思考是个前缀等于后缀的问题,用kmp的next数组模板 假设t[0..l-1]==t[n-l....n-1] 那么应该不断重复t[l...n-1]这样的子串 代码如下(应该好好记住

Codeforces Round #506 (Div. 3) 题解

Codeforces Round #506 (Div. 3) 题目总链接:https://codeforces.com/contest/1029 A. Many Equal Substrings 题意: 给出长度为n的字符串,然后要求你添加一些字符,使得有k个这样的字符串. 题解: 直接暴力吧...一个指针从1开始,另一个从2开始,逐一比较看是否相同:如果不同,第一个指针继续回到1,第二个指针从3开始...就这么一直重复.最后如果第二个指针能够顺利到最后一位,那么记录当前的第一个指针,把他后面的

April Fools Contest 2017 题解&amp;源码(A,数学 B,数学 C,数学 D,字符串 E,数字逻辑 F,排序,卡时间)

A. Numbers Joke time limit per test:2 seconds memory limit per test:64 megabytes input:standard input output:standard output Input The input contains a single integer a (1 ≤ a ≤ 30). Output Output a single integer. Example Input 3 Output 27 题目链接:http

[Creating an image format with an unknown type is an error] on cordova, ios 10

在 iOS 10  调用 了 获取  相册的 可编辑 的  照片后,会出现 [Creating an image format with an unknown type is an error] 这个其实不影响app的使用,这个是 iOS10 系统的bug 而已.其实 程序员进行二次调用的时候  并没有  所谓的error.

ACM: POJ 3660 Cow Contest - Floyd算法

链接 Cow Contest Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Eac