标签:
#include <iostream> #include <algorithm> #include <cstring> using namespace std; int ans; struct node { int time; int fen; } work[1005]; bool cmp(const node &a,const node &b) { if(a.fen>b.fen) return true; else if(a.fen==b.fen) { if(a.time<b.time) return true; else return false; } else return false; } int main() { int t,n; int ss[1005]; cin>>t; while(t--) { memset(ss,0,sizeof(ss)); ans=0; cin>>n; for(int i=0;i<n;i++) cin>>work[i].time; for(int i=0;i<n;i++) cin>>work[i].fen; sort(work,work+n,cmp); //for(int i=0;i<n;i++) //cout<<work[i].time<<" "<<work[i].fen<<endl; for(int i=0;i<n;i++) { int j=work[i].time; while(j--) { if(ss[j]==0) { ss[j]=1; break; } } if(ss[j]!=1) ans+=work[i].fen; } cout<<ans<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/nefu929831238/p/5349722.html