高端操作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>
#include<algorithm>
#include<cmath>
#include<bitset>
#define inf 20021225
#define ll long long
#define mxn 2100
using namespace std; int n,s[mxn],a[mxn];
bitset<4000500> b;
int main()
{
int sum = 0;
scanf("%d",&n); b[0]=1;
for(int i=1;i<=n;i++)
scanf("%d",&a[i]),b|=b<<a[i],sum+=a[i];
sum = (sum+1)>>1;
while(!b[sum]) sum++;
printf("%d\n",sum);
return 0;
}

AGC020C Median Sum的更多相关文章

  1. AtCoder3857:Median Sum (Bitset优化背包&&对称性求中位数)

    Median Sum You are given N integers A1, A2, ..., AN. Consider the sums of all non-empty subsequences ...

  2. Atcoder 3857 Median Sum

    Problem Statement You are given N integers A1, A2, ..., AN. Consider the sums of all non-empty subse ...

  3. 2018.08.10 atcoder Median Sum(01背包)

    传送门 题意简述:输入一个数组an" role="presentation" style="position: relative;">anan. ...

  4. [AT3857]Median Sum

    题目大意:给定$n$个数,第$i$个数为$a_i$,记这$n$个数的所有非空子集的和分别为$s_1,s_2,\dots,s_{2^n-1}$:求$s$的中位数. 题解:假设考虑的是所有子集,包括空子集 ...

  5. DP题组

    按照顺序来. Median Sum 大意: 给你一个集合,求其所有非空子集的权值的中位数. 某集合的权值即为其元素之和. 1 <= n <= 2000 解: 集合配对,每个集合都配对它的补 ...

  6. atcoder题目合集(持续更新中)

    Choosing Points 数学 Integers on a Tree 构造 Leftmost Ball 计数dp+组合数学 Painting Graphs with AtCoDeer tarja ...

  7. 【AtCoder】AGC020

    A - Move and Win 题解 看两个人相遇的时候谁先手即可,相遇之后第一个移动的人必输 代码 #include <bits/stdc++.h> #define fi first ...

  8. pandas高级操作总结

    1.pandas中的列的分位数 # 查看列的分位数 import pandas as pd # set columns type my_df['col'] = my_df['col'].astype( ...

  9. 【Bitset】重识

    ---------------------------------------------------------------------------- 一题题目: 一题题解: 这个题目哪来入门再好不 ...

随机推荐

  1. Cookie由谁设置、怎么设置、有什么内容?

    Cookie是由服务器生成,保存在客户端本地的一个文件,通过response响应头的set-Cookie字段进行设置,下面是一个示例: Cookie包含什么信息? 它可以记录你的用户ID.密码.浏览过 ...

  2. 组件Component详解

    [转]https://www.cnblogs.com/moqiutao/p/8328931.html

  3. matlab: undocumented sprintfc

    今天本想找一个类似于 R 中 paste 的 matlab 函数, 结果在 stackoverflow 上找到一个叫 sprintfc 的函数 (http://stackoverflow.com/qu ...

  4. redhat 修改yum源

    问题现象: 现有的yum安装git失败,提示yum源连接失败 Error Downloading Packages: git--.el6_4..x86_64: failure: Packages/gi ...

  5. ab工具进行压力测试

    简介与安装 ab:Apache Benchmark,只要我们安装了Apache,就能够在Apache的安装目录中找到它. yum | apt 安装的Apache  ab的目录一般为/usr/bin 也 ...

  6. 【C#学习笔记】string.Format对C#字符串格式化

    文章转自:CSDN   http://blog.csdn.net/samsone/article/details/7556781 1.格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格 ...

  7. spring事务——try{...}catch{...}中事务不回滚的几种处理方式(转载)

    转载自   spring事务——try{...}catch{...}中事务不回滚的几种处理方式   当希望在某个方法中添加事务时,我们常常在方法头上添加@Transactional注解 @Respon ...

  8. org.hibernate.id.IdentifierGenerationException: Hibernate异常

    异常信息: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned b ...

  9. C#=> 栈模仿堆的操作

    //原理,利用两个栈,互相作用,来模仿堆的效果,先进先出.. using System; using System.Collections.Generic; using System.Linq; us ...

  10. [CF580C]Shortest Cycle(图论,最小环)

    Description: 给 \(n\) 个点的图,点有点权 \(a_i\) ,两点之间有边当且仅当 \(a_i\ \text{and}\ a_j \not= 0\),边权为1,求最小环. Solut ...