hdu 4666 Hyperspace
来源:互联网 发布:js 原生排序 编辑:程序博客网 时间:2024/05/20 20:43
n维最远曼哈顿距离。。
#include<iostream>#include<algorithm>#include<string.h>#include<stack>#include<set>#include<queue>#include<math.h>#include<cstdio>using namespace std;const int inf=0x7ffffff;const int maxn=60010;struct st{ int a[6],b[35];}s[maxn];multiset<int> data[35];int n,k;void work(int id){ for(int i=0;i<(1<<k);i++) { int sum=0; for(int j=0;j<k;j++) { if(i&(1<<j)) sum+=s[id].a[j]; else sum-=s[id].a[j]; } s[id].b[i]=sum; }}void add(int id){ work(id); for(int i=0;i<(1<<k);i++) data[i].insert(s[id].b[i]);}void del(int id){ for(int i=0;i<(1<<k);i++) data[i].erase(data[i].find(s[id].b[i]));}int getans(){int ans=-inf; for(int i=0;i<(1<<k);i++) { int a=*(data[i].rbegin()); int b=*(data[i].begin()); if(a-b>ans) ans=a-b; } return ans;}int main(){ int op,a,b; while(scanf("%d%d",&n,&k)==2) {int cnt=0; for(int i=1;i<=n;i++) { scanf("%d",&op); if(op==0) { for(int j=0;j<k;j++) scanf("%d",&s[i].a[j]); add(i); cnt++; } else if(op==1) { scanf("%d",&a); del(a); cnt--; } if(cnt<2) { puts("0"); continue; } printf("%d\n",getans()); } for(int i=0;i<(1<<k);i++) data[i].clear(); } return 0;}
- HDU 4666 Hyperspace
- hdu-4666 Hyperspace
- hdu 4666 Hyperspace
- HDU 4666 Hyperspace
- hdu 4666 Hyperspace
- HDU 4666 Hyperspace
- hdu 4666Hyperspace
- HDU 4666 Hyperspace
- HDU 4666 Hyperspace
- HDU——4666 Hyperspace
- HDU 4666 Hyperspace 解题报告
- Hdu-4666 Hyperspace(曼哈顿距离)
- hdu 4666 Hyperspace 多校第七场
- hdu-4666-Hyperspace-最长曼哈顿距离
- [HDU 4666]Hyperspace[最远曼哈顿距离][STL]
- hdu 4666 Hyperspace (曼哈顿距离+set )
- [HDU 4666]Hyperspace[最远曼哈顿距离][STL]
- HDU 4666 Hyperspace(最长曼哈顿距离)
- Topcoder好题推荐 ( 持续更新中 )
- 在myeclipse中, 如何还原默认窗口?
- vb.net中将DataGridView与数据源绑定
- zoj 1967 Fiber Network
- HDU 1203 贪心或者DP
- hdu 4666 Hyperspace
- hdu1506 Largest Rectangle in a Histogram
- 工作中的准则--体会
- PHP实现把数字ID转字母ID
- 日期计算
- 关于Java的界面编写
- 模块式编译的Makefile
- spring原理
- read a line with arbitrary length using fgets