首页 > 其他 > 详细

POJ 3614

时间:2019-03-03 12:53:24      阅读:157      评论:0      收藏:0      [点我收藏+]

http://poj.org/problem?id=3614‘

1:奶牛的min和瓶子spx值从大到小排序

技术分享图片
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)
using namespace std;
struct node
{
    int a,b;
}x[3000];
struct hhh
{
    int c,d;
}y[3000];
bool cmp1(node one,node two)
{
    return one.a>two.a;
}
bool cmp2(hhh one ,hhh two )
{
    return one.c>two.c;
}
int C,L,ans;
int main()
{
    cin>>C>>L;
    FOR(i,1,C)
    {
        cin>>x[i].a>>x[i].b;
    }
    FOR(i,1,L)
    {
        cin>>y[i].c>>y[i].d;
    }

    sort(x+1,x+1+C,cmp1);
    sort(y+1,y+1+L,cmp2);

    for(int i=1;i<=C;++i)
    {
        for(int j=1;j<=L;++j)
        {
            if(y[j].c<=x[i].b&&y[j].c>=x[i].a&&y[j].d>0)
            {
                y[j].d--;
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}
one

2:奶牛的max和瓶子的spf从小到大排序

技术分享图片
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <vector>
//const int maxn = 1e5+5;
#define ll long long
#define MAX INT_MAX
#define FOR(i,a,b) for( int i = a;i <= b;++i)
using namespace std;
struct node
{
    int a,b;
}x[3000];
struct hhh
{
    int c,d;
}y[3000];
bool cmp1(node one,node two)
{
    return one.b<two.b;
}
bool cmp2(hhh one ,hhh two )
{
    return one.c<two.c;
}
int C,L,ans;
int main()
{
    cin>>C>>L;
    FOR(i,1,C)
    {
        cin>>x[i].a>>x[i].b;
    }
    FOR(i,1,L)
    {
        cin>>y[i].c>>y[i].d;
    }
    
    sort(x+1,x+1+C,cmp1);
    sort(y+1,y+1+L,cmp2);
    
    for(int i=1;i<=C;++i)
    {
        for(int j=1;j<=L;++j)
        {
            if(y[j].c<=x[i].b&&y[j].c>=x[i].a&&y[j].d>0)
            {
                y[j].d--;
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}
2

 

POJ 3614

原文:https://www.cnblogs.com/jrfr/p/10464609.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!