标签:des style blog http color os io strong ar
1 #include<cstdio> 2 #include<cstdlib> 3 #include<cmath> 4 #include<cstring> 5 #include<algorithm> 6 #include<iostream> 7 #include<vector> 8 #include<map> 9 #include<set> 10 #include<queue> 11 #include<string> 12 #define inf 1000000000 13 #define maxn 50000+100 14 #define maxm 500+100 15 #define eps 1e-10 16 #define ll long long 17 #define pa pair<int,int> 18 using namespace std; 19 inline int read() 20 { 21 int x=0,f=1;char ch=getchar(); 22 while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();} 23 while(ch>=‘0‘&&ch<=‘9‘){x=10*x+ch-‘0‘;ch=getchar();} 24 return x*f; 25 } 26 int n; 27 struct rec{int x,y;}a[maxn]; 28 inline bool cmp(rec a,rec b) 29 { 30 return a.x+a.y<b.x+b.y; 31 } 32 int main() 33 { 34 freopen("input.txt","r",stdin); 35 freopen("output.txt","w",stdout); 36 n=read(); 37 for(int i=1;i<=n;i++)a[i].x=read(),a[i].y=read(); 38 sort(a+1,a+n+1,cmp); 39 int sum=0,ans=-inf; 40 for(int i=1;i<=n;i++) 41 { 42 ans=max(ans,sum-a[i].y); 43 sum+=a[i].x; 44 } 45 printf("%d\n",ans); 46 return 0; 47 }
BZOJ1629: [Usaco2007 Demo]Cow Acrobats
标签:des style blog http color os io strong ar
原文地址:http://www.cnblogs.com/zyfzyf/p/3942207.html