高端操作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. Angular:OnPush变化检测策略介绍

    在OnPush策略下,Angular不会运行变化检测(Change Detection ),除非组件的input接收到了新值.接收到新值的意思是,input的值或者引用发生了变化.这样听起来不好理解, ...

  2. Cluster基础(四):创建RHCS集群环境、创建高可用Apache服务

    一.创建RHCS集群环境 目标: 准备四台KVM虚拟机,其三台作为集群节点,一台安装luci并配置iSCSI存储服务,实现如下功能: 使用RHCS创建一个名为tarena的集群 集群中所有节点均需要挂 ...

  3. Java并发指南14:JUC中常用的Unsafe和Locksupport

    本文转自网络,侵删 本系列文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到我的仓库里查看 https://github.com/h2pl/Java-Tutoria ...

  4. yum安装Development Tools报错问题

    yum安装Development Tools报错问题 我们通过yum安装Development Tools开发组工具的时候,有时可能会遇到如下报错信息. [root@superdesktop ~]# ...

  5. HTML--JS 表单验证

    <html> <head> <title>验证表单</title> <script type="text/javascript" ...

  6. 【ABAP系列】SAP smartforms金额字段产生空格,除去空格的方法

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP smartforms金额 ...

  7. Item-Based Collaborative Recommender System

    与User-Based Collaborative Recommender System认为‘类似的用户会对同一个item给出类似的打分’不同,Item-Based Collaborative Rec ...

  8. 微信小程序这一块(上)

    1.根目录下面的文件: 凡是以app开头的都是全局配置文件 app.js 全局逻辑文件 注册小程序 app.json 全局配置文件 https://developers.weixin.qq.com/m ...

  9. Waiter.js

    var Waiter = function() {     var dfd = [],         doneArr = [],         failArr = [],         slic ...

  10. css中word-break、word-wrap和white-space的区别

    css中word-break.word-wrap和white-space的区别 :https://baijiahao.baidu.com/s?id=1578623236521030997&wf ...