| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
随便暴力都能过#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <map>
#include <cstdlib>
#include <algorithm>
#define max(a,b) (a>b?a:b)
using namespace std;
struct node {
int x,y;
}k[10005];
int vis[10005];
int cmp(node x,node y){
if(x.x==y.x)return x.y>y.y;
return x.x>y.x;
}
int erfen(int u){
int r=u-1;
while(r>=0){
if(vis[r])r--;
else break;
}
return r;
}
int main(){
int n;
while(cin>>n){
int sum=0;
for(int i=0;i<n;i++){
scanf("%d%d",&k[i].x,&k[i].y);
}
sort(k,k+n,cmp);
memset(vis,0,sizeof(vis));
for(int i=0;i<n;i++){
// cout<<k[i].x<<" "<<k[i].y<<endl;
int t=erfen(k[i].y);
if(t!=-1){
// cout<<k[i].x<<" "<<k[i].y<<" "<<t<<endl;
sum+=k[i].x;
vis[t]=1;
}
}
printf("%d\n",sum);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator