二分,尺取法,细节模拟,尤其是要注意a[i]被计算到和a[i]成对的a[j]里时 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; int n; long long k; bool check(long long x){ ;//比x小的个数 ;i<=n;++i){ ){ long long flag=x/a[i]; if(x%a[i]){ &&a[i]<){//x
/** 题目:D - No Need 链接:http://arc070.contest.atcoder.jp/tasks/arc070_b 题意:给出N个数,从中选出一个子集,若子集和大于等于K,则这是一个Good子集,现在要求这N个数里无用数的个数. 无用数的定义是:在这个数所属的所有Good子集中,如果把这个数删去后原子集仍然是一个Good子集,它就是一个无用数 思路:关键点是存在单调性,如果某个数是必须的,那么比他大的数都是必须的: 证明如下:假设x是必须的,y是比x大的某个数:x是必须的
D - AtCoder Express Time limit : 2sec / Memory limit : 256MB Score : 400 points Problem Statement In the year 2168, AtCoder Inc., which is much larger than now, is starting a limited express train service called AtCoder Express. In the plan developed
题目链接:http://abc063.contest.atcoder.jp/tasks/arc075_b 题解:直接二分答案然后再判断(a-b)来替代不足的.看代码比较好理解,水题. #include <iostream> #include <cstring> #include <cstdio> using namespace std; typedef long long ll; const int M = 1e5 + 10; ll num[M]; ll n , a ,
原文链接https://www.cnblogs.com/zhouzhendong/p/ARC101D.html 题目传送门 - ARC101D 题意 给定一个序列 A . 定义一个序列 A 的中位数为:给 A 排序,得到的第 $\left\lfloor\cfrac{i}{2}\right\rfloor+1$ 项的值. 序列 B 由序列 A 的所有连续子序列的中位数构成. 问序列 B 的中位数是多少. 序列中可能出现重复的数,$|A| \leq 10^5$ . 题解 注意这里说的“中位数”是题意里
D - Median of Medians Time limit : 2sec / Memory limit : 1024MB Score : 700 pointsProblem Statement We will define the median of a sequence b of length M, as follows: Let b' be the sequence obtained by sorting b in non-decreasing order. Then, the
Problem Statement This is an interactive task. Snuke has a favorite positive integer, N. You can ask him the following type of question at most 64 times: "Is n your favorite integer?" Identify N. Snuke is twisted, and when asked "Is n your
Problem Statement You are given two integer sequences, each of length N: a1,…,aN and b1,…,bN. There are N2 ways to choose two integers i and j such that 1≤i,j≤N. For each of these N2 pairs, we will compute ai+bj and write it on a sheet of paper. That
二分水题,A,B,C三个数组排序,对于每个B[i],二分算出来有多少A比他小,多少C比他大,然后扫一遍出结果.O(nlog(n))水过. #include <bits/stdc++.h> using namespace std; const int MAXN = 1e5+10; int A[MAXN],B[MAXN],C[MAXN]; int n; //严格小于B[i]的数字个数 和 严格大于B[i]的数字个数 long long lnb[MAXN],unb[MAXN]; int main()