UVALive 7483 Air Conditioned Minions

UVALive 7483(2015 新加坡区域赛)

本来是水题一枚,结果卡了好久,后来换了一种机智的方法过了。

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5506

You are the boss of ACM (Air Conditioned Minions), an upstanding company with a single goal of world domination. The company has N minions. Each minion works evilly from early morning until evening inside a super secret bunker in Helsinki. After much deliberation, you decided to move your headquarters to Singapore. However, unlike Helsinki, Singapore is very hot, so the entire complex must be air conditioned. With strenuous working hours (under minimum wage too), it is imperative that all your minions work under optimal work condition. In particular, all minions must like the temperatures of the rooms they are in. You are planning to construct several rooms in your new hideout, and assign your minions there. You fix the temperature of each room to any value you want (different rooms may have different temperatures). After you fix the temperatures, you will assign each of your minions to these rooms (a room can hold any number of minions). You want all minions to like the temperatures of their assigned rooms. Each minion likes an interval of temperature, and these preferences will be given to you. Air conditioners are very expensive to maintain. Thus, you want to construct as few rooms as possible. What is the minimum number of rooms you need to set up such that it would be possible to assign minions to rooms as discussed earlier?

Input
The input file contains several test cases, each of them as described below. The first line contains a non-negative integer 2 ≤ N ≤ 100, giving the number of minions in your company. The next N lines each describe the temperature preferences of all your minions. The i-th line consists of two single space separated integers L and U (1 ≤ L ≤ U ≤ 2N), which denotes that the i-th minion likes any temperature between L and U, inclusively.

Output
For each case, print an integer denoting the minimum number of rooms you need to construct on a line by itself. Explanation: In the first example, one of the possible solutions is to setup two rooms — one with temperature 2, and another with temperature 5. The first two minions can be assigned to the first room, while the third minion can be assigned to the second room.

Sample Input
3
1 2
2 4
5 6
5
1 2
3 5
4 6
7 9
8 10
Sample Output
2
3

#include <bits/stdc++.h>
using namespace std;

#define pb push_back

int main()
{
    int N;
    while(cin>>N){
        vector <int> arr[201];
        for (int i=1;i<=N;i++){
            int a, b;
            scanf("%d%d",&a,&b);
            arr[a].pb(b);
        }
        int mn=2e9, ans=0;
        for (int i=1;i<=N+N;i++){
            if (mn < i) ans++, mn = 2e9;
            for(int j=0;j<arr[i].size();j++)
            {
                int e=arr[i][j];
                mn=min(mn,e);
            }
        }
        if (mn < 2e9) ans++;
        printf("%d\n", ans);
    }
    return 0;
}


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值