请问:挖掘机技术哪家强?AC了告诉你!
给你N(N<=3*10^4)个任务,每个任务有一个截止完成时间t(1=<t<=10^9)和完成该任务的奖励v(1=<v<=10^9),每个任务要花一天完成,问最多能获得多少奖励?

7 4 20 2 60 4 70 3 40 1 30 4 50 6 10
230
代码:
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define M 30500
struct node{
int t, v;
}s[M];
int fat[M];
bool cmp(node a, node b){
return a.v > b.v;
}
int f(int x){
if(fat[x] <= 0) return -1;
else if(fat[x] == x) return fat[x] = x-1;
else fat[x] = f(fat[x]);
}
int main(){
int n;
while(scanf("%d", &n) == 1){
int i;
for(i = 0; i < n; i ++){
scanf("%d%d", &s[i].t, &s[i].v);
fat[i] = i;
if(s[i].t > n) s[i].t = n;
}
fat[n] = n;
sort(s, s+n, cmp);
long long sum = 0;
for(i = 0; i < n; i ++){
if(f(s[i].t) >= 0){
sum += s[i].v;
}
}
printf("%lld\n", sum);
}
return 0;
} 原文:http://blog.csdn.net/shengweisong/article/details/41822297