Eugeny has array a = a1, a2, ..., an, consisting of n integers. Each integer ai equals to -1, or to 1. Also, he has m queries: Query number i is given as a pair of integers li, ri (1 ≤ li ≤ ri ≤ n). The response to the query will be integer 1, if the…
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 8541    Accepted Submission(s): 1982 Problem Description We are all familiar with sorting algorithms: quick sort, merge sort…
Codeforces Round #258 (Div. 2) Sort the Array B. Sort the Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Being a programmer, you like arrays a lot. For your birthday, your friends ha…
B. Wilbur and Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/596/problem/B Description Wilbur the pig is tinkering with arrays again. He has the array a1, a2, ..., an initially consisting of n zeros. At one step, he…
A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an array of n elements, you must make it a co-prime array in as few moves as possible. In each move you can insert any positive integral number you want…
题目链接: A. Co-prime Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array of n elements, you must make it a co-prime array in as few moves as possible. In each move you…
题目链接: B. Amr and The Large Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output   Amr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller. Amr d…
题目链接 /* Name: Copyright: Author: Date: 2018/5/6 19:34:23 Description: */ #include <iostream> #include <cstdio> #include <cstring> using namespace std; ]; int main() { int n; while (cin>>n) { ; i<n; i++) { cin>>arr[i]; } )…
11.07图论水题Test 题目 描述 做法 \(BSOJ6378\) 在\(i\)位置可以到\(i+a_i\)或\(i+b_i\)求\(1\rightarrow n\)字典序最小路径 判可达性后贪心\(dfs\) \(BSOJ5154\) 过长 裸的期望\(dp\) \(BSOJ5155\) 多次询问:树上路径\(x\)到\(y\),初始\(c\)元,每次碰到比当前最大值大的就买,求购买次数 倍增预处理,二分 \(T1\) 注意数组含义(\(vis\&able\)) \(T2\) 注意概率不是…
11.06水题比赛 题目 描述 做法 \(BSOJ5150\) 求\(n\)个数两两之差的中位数 二分中位数,双指针判定\(\le x\)差值对数 \(BSOJ5151\) 求树的最大匹配和其个数 来一遍\(dp\),转移中途计数 \(BSOJ5152\) 求丢一张麻将后最大听牌数 爆搜 \(T1\) 二分中位数,从小到大求出每个点与最小的使得他们差值小于等于\(x\)的位置累加区间,判定两倍是否多于\(\frac{n(n-1)}{2}\) 注意偶数还要二分一次以\(\frac{n(n-1)}{…