poj 2287
来源:互联网 发布:淘宝订单信息编辑 编辑:程序博客网 时间:2024/06/06 10:05
贪心,没完全理解啊,明天再想想,今天已经想了一天了,唉
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 using namespace std; 5 const int maxn=1000+10; 6 int tian[maxn],qi[maxn]; 7 int main() 8 { 9 int n;10 while(scanf("%d",&n)&&n)11 {12 int i,j;13 for(i=1;i<=n;i++) scanf("%d",&tian[i]);14 for(i=1;i<=n;i++) scanf("%d",&qi[i]);15 sort(tian+1,tian+n+1);16 sort(qi+1,qi+n+1);17 int front1=1,rear1=n,front2=1,rear2=n;18 int ans=0;19 while(front1<=rear1)20 {21 if(tian[front1]<qi[front2])22 {23 ans-=200;24 front1++;25 rear2--;26 }27 else if(tian[front1]>qi[front2])28 {29 ans+=200;30 front1++;31 front2++;32 }33 else34 {35 if(tian[rear1]<=qi[rear2])36 {37 if(tian[front1]<qi[rear2]) ans-=200;38 front1++;39 rear2--;40 }41 else42 {43 rear1--;44 rear2--;45 ans+=200;46 }47 }48 }49 printf("%d\n",ans);50 }51 return 0;52 }
- POJ 2287
- poj 2287
- poj 2287
- hdoj 1052 || poj 2287
- poj 2287 动态规划
- POJ 2287贪心算法
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- poj 3128
- poj 3368
- 十个利用矩阵乘法解决的经典题目
- poj 1815
- poj 3928
- poj 2287
- Jenkins+Maven+SVN搭建自动部署,自动测试环境
- hdu 3714
- poj 3691
- POJ-2739-Sum of Consecutive Prime Numbers
- hdu 2825
- hdu 4547
- poj 2778
- poj 1743