hdu 4296 贪心
来源:互联网 发布:我知女人心 结局 编辑:程序博客网 时间:2024/05/29 17:13
http://acm.hdu.edu.cn/showproblem.php?pid=4296
找sum-w[i]-s[i]的最小值就行了,O(n)
//#pragma comment(linker, "/STACK:102400000,102400000")#include <cstdio>#include <cstring>#include <algorithm>#include <string>#include <iostream>#include <iomanip>#include <cmath>#include <map>#include <set>#include <queue>using namespace std;#define ls(rt) rt*2#define rs(rt) rt*2+1#define ll long long#define ull unsigned long long#define rep(i,s,e) for(int i=s;i<e;i++)#define repe(i,s,e) for(int i=s;i<=e;i++)#define CL(a,b) memset(a,b,sizeof(a))#define IN(s) freopen(s,"r",stdin)#define OUT(s) freopen(s,"w",stdout)const ll ll_INF = ((ull)(-1))>>1;const double EPS = 1e-8;const double pi = acos(-1.0);const int INF = 100000000;const int MAXN = 100000+20;int w[MAXN],s[MAXN];int main(){ int n,pos; ll sum,mmin; while(~scanf("%d",&n)) { sum=0; for(int i=0;i<n;i++) scanf("%d%d",&w[i],&s[i]),sum+=w[i]; mmin=sum-w[0]-s[0]; pos=0; for(int i=1;i<n;i++) if(mmin>sum-w[i]-s[i])pos=i,mmin=sum-w[i]-s[i]; printf("%I64d\n",mmin); } return 0;}
0 0
- hdu 4296(贪心)
- HDU 4296 Buildings(贪心)
- hdu 4296 贪心
- hdu 4296 贪心
- hdu 4296 Buildings(贪心)
- 贪心-- HDU - 4296 Buildings
- HDU 4296 Buildings 贪心
- HDU 4296 Buildings(贪心)
- hdu 4296 Buildings(贪心)
- HDU 贪心
- 【贪心】hdu
- hdu 4296 坑爹的 贪心
- hdu 4296 Buildings 贪心 解题报告
- HDU 2111 Saving HDU(贪心)
- HDU 2111贪心--【Saving HDU】
- HDU 2111 Saving HDU (贪心)
- HDU Saving HDU (贪心)
- HDU 2111 Saving HDU【贪心】
- 黑马程序员-day02java语言基础组成1
- epoll详解
- C++ concepts: Compare
- Mac使用Git说明
- FreeSwitch Sip
- hdu 4296 贪心
- Sprite Kit教程:初学者
- UML初级学习之用例图
- 【翻译】两种高性能I/O设计模式(Reactor/Proactor)的比较
- 集群搭建必备:nat模式设置静态ip,达到上网与主机相互通信
- tp页面间传参注意事项
- 浅析vs2008中 Run-Time Check Failure #2 - Stack around the variable 'var' was corrupted
- 对哈希表的小见——再散列(嵌套)
- Flex组件开发阶段小结