c++代码

贡献者:游客6594218 类别:代码 时间:2016-04-02 23:48:27 收藏数:268 评分:0
返回上页 举报此文章
请选择举报理由:




收藏到我的文章 改错字
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef struct
{
int p, d;
}node;
node a[10000+10];
bool flag[10000+10];
bool cmp(node a, node b)
{
return a.p > b.p;
}
int main()
{
//freopen("data.in" , "r" , stdin);
int n ;
while(scanf("%d", &n) != EOF)
{
memset(flag , true , sizeof(flag));
for(int i = 0 ; i < n ; i ++)
scanf("%d %d", &a[i].p, &a[i].d);
sort(a , a + n , cmp);
int ans = 0;
for(int i = 0 ; i < n ; i ++)
{
for(int j = a[i].d ; j > 0 ; j --)
{
if(flag[j])
{
flag[j] = false;
ans += a[i].p;
break;
}
}
}
printf("%d\n" , ans );
}
return 0;
}
声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。
文章热度:
文章难度:
文章质量:
说明:系统根据文章的热度、难度、质量自动认证,已认证的文章将参与打字排名!

本文打字排名TOP20

登录后可见

用户更多文章推荐