#include<bits/stdc++.h>
using namespace std;
struct node
{
int w,t;
};
bool compare(const node &x,const node &y)
{
return x.w>y.w;
}
class Solution
{
public:
map < int , bool > vis;
int ans,flag;
int solution(vector < node > num)
{
ans=flag=0;
sort(num.begin(),num.end(),compare);
for(int i=0; i<num.size(); i++)
{
flag=1;
for(int j=num[i].t; j>=1; j--)
{
if(vis[j]==false)
{
vis[j]=true;
flag=0;
break;
}
}
if(flag)
{
ans+=num[i].w;
for(int j=num.size(); j>=1; j--)
{
if(vis[j]==false)
{
vis[j]=true;
break;
}
}
}
}
return ans;
}
};
int main()
{
vector < node > x;
Solution X;
int n,m;
cin>>m>>n;
for(int i=1,y; i<=n; i++)
{
cin>>y;
x.push_back((node){0,y});
}
for(int i=1,y; i<=n; i++)
{
cin>>y;
x[i-1].w=y;
}
cout<<m-X.solution(x)<<endl;
}
标签:10004,node,1.1,int,vis,flag,num,ans,冲浪
From: https://www.cnblogs.com/dadidididi/p/16599519.html