是#3
by Morning__star @ 2024-02-27 21:05:50
```
#include<bits/stdc++.h>
using namespace std;
struct w{
long long p,a;
}c[1000000];
bool cmp(w a,w b)
{
return a.p<b.p;
}
int main()
{
int n,m,sum=0,t=0;
cin>>n>>m;
for(int i=0;i<m;i++)
{
cin>>c[i].p>>c[i].a;
}
sort(c,c+m,cmp);
int x=0;
while(t<=n&&x<=n)
{
if(t+c[x].a>n)
{
sum=sum+c[x].p*(n-t);
break;
}else{
sum=sum+c[x].p*c[x].a;
t=t+c[x].a;
}
x++;
}
cout<<sum;
return 0;
}
```
AC代码
by wran @ 2024-03-26 20:09:44