Atcoder 3857 Median Sum】的更多相关文章

Problem Statement You are given N integers A1, A2, ..., AN. Consider the sums of all non-empty subsequences of A. There are 2N−1 such sums, an odd number. Let the list of these sums in non-decreasing order be S1, S2, ..., S2N−1. Find the median of th…
Median Sum You are given N integers A1, A2, ..., AN. Consider the sums of all non-empty subsequences of A. There are 2N−1 such sums, an odd number. Let the list of these sums in non-decreasing order be S1, S2, ..., S2N−1. Find the median of this list…
传送门 题意简述:输入一个数组an" role="presentation" style="position: relative;">anan. 对于所有2n−1" role="presentation" style="position: relative;">2n−12n−1个非空子集,每个子集的权值是包含的所有元素之和. 求这2n−1" role="presentatio…
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…
题目大意:给定一个 N 个点的序列,求有多少个区间满足\(\oplus_{i=l}^ra[i]=\sum\limits_{i=l}^ra[i]\). 题解: 小结论:\(a\oplus b=a+b\rightarrow a\&b=0\). 对每个点来说,考虑向右延伸能够满足条件的右端点的位置,显然右端点的位置单调不减,双指针扫一遍即可. 代码如下 #include <cstdio> using namespace std; const int maxn=2e5+10; int n,a[…
题目大意:给定$n$个数,第$i$个数为$a_i$,记这$n$个数的所有非空子集的和分别为$s_1,s_2,\dots,s_{2^n-1}$:求$s$的中位数. 题解:假设考虑的是所有子集,包括空子集. 令$sum=\sum\limits_{t=1}^n a_i$. 若有一个子集和为$x$,存在另一个子集和为$sum-x$. 因此不含空子集的中位数等价于所有出现过的数的中间两个的后一个. $0/1$背包就好了,可以用$bitset$优化 卡点:无 C++ Code: #include <cstd…
高端操作qaq 又双叒叕读错题了= = 然后重新读题发现不会做了 于是瞅了一波题解 我靠要不要这么暴力呜呜呜 直接bitset O(n^3/w)QAQ 就是f[i]表示i是否能被搞出来 然后我们先不看2^n-1 补上空集就是2^n 然后这就两两对应分出组了 然后我们要找的就是比(sum+1)/2大的第一个元素 bitset强上= = 学习一发bitset正确优化姿势也海星 //Love and Freedom. #include<cstdio> #include<cstring>…
题目链接:https://atcoder.jp/contests/abc129/tasks/abc129_e 题目大意 给定一个二进制表示的数 L,问有多少对自然数 (a, b) 满足 $a + b \leq L 且 a + b = a \oplus b $. 分析 由于异或是无进位相加,所以 $a + b = a \oplus b $ 等价于 a 和 b 的每一位对应二进制位都不会是两个 1. 设 L 有 n 个 1.按 L 中的顺序编号为 n~1. 设 L(i) 为编号为 i 的 1 到 L…
Choosing Points 数学 Integers on a Tree 构造 Leftmost Ball 计数dp+组合数学 Painting Graphs with AtCoDeer tarjan+polya Building Cubes with AtCoDeer 枚举 AtCoDeer and Election Report 贪心 Snuke's Coloring 思维题 Snuke's Coloring 2 线段树+单调栈 Make Them Even 贪心 1D Reversi 模…
A - Move and Win 题解 看两个人相遇的时候谁先手即可,相遇之后第一个移动的人必输 代码 #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define pdi pair<db,int> #define mp make_pair #define pb push_back #define enter putchar('\n') #def…