http://acm.hdu.edu.cn/showproblem.php?pid=3661

 

貌似是道很简单的贪心,结果让我搞的。。。唉,不在状态啊... 

 

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std ;

int at[1005], bt[1005] ;
int cmp(int a, int b){
    return a>b ;
}
int main(){
    int n, t, i ;
    while(~scanf("%d%d", &n, &t)){
        int sum = 0 ;
        for(i=0; i<n; i++)
            scanf("%d", &at[i]) ;
        for(i=0; i<n; i++)
            scanf("%d", &bt[i]) ;
        sort(at, at+n) ;
        sort(bt, bt+n, cmp) ;
        for(i=0; i<n; i++){
            if(at[i]+bt[i]>=t)
                sum += at[i]+bt[i]-t ;
        }
        printf("%d\n", sum) ;
    }
    return 0 ;

} 

posted on 2011-11-19 19:18  追逐.  阅读(227)  评论(0编辑  收藏  举报