摘要:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1203这是道贪心题,要求最少的救生圈的个数。先将每个人要求的救生圈范围 a 、b按照b的升序、b相等的时候按照a的降序排序。将第一个的b作为第一个判断点,直到第i个人的a大于之前的b,再将b换成第i个b,依此类推!#include<iostream>#include<stdlib.h>using namespace std;typedef struct d{ int a; int b;}B;B t[10005];int cmp( const void *_p, const 阅读全文
posted @ 2011-11-21 14:16
找回失去的
阅读(199)
评论(0)
推荐(0)
摘要:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1208亏我还想用并查集去做,这道题用数组模拟链表就行,数组下标为编号,一个一个接下去就行,在接的同时计数。这题有点恶心的是必须把数组开到101000以上,要不就会RE,这也是考查的一个方面吧!#include<iostream>#include<string.h>using namespace std;const int N = 101005;int next[N];int main(){ int n, m; int a, b; while( cin >> n 阅读全文
posted @ 2011-11-21 14:11
找回失去的
阅读(369)
评论(0)
推荐(0)
浙公网安备 33010602011771号