#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,t,k;
struct node{
int c,d;
double xjb;
}a[N];
bool cmp(node x,node y){
return x.xjb>y.xjb;
}
int main()
{
cin>>k;
while(k--){
cin>>t>>n;
for (int i=0;i<n;i++){
cin>>a[i].c>>a[i].d;
a[i].xjb=1.0*a[i].d/a[i].c;
}
sort(a,a+n,cmp);
double ans=0;
for (int i=0;i<n;i++){
if (a[i].c<=t) {
t-=a[i].c;
ans+=a[i].d;
}
else{
ans+=(a[i].xjb*t);
break;
}
}
printf("%.2lf\n",ans);
}
return 0;
}
10-19
1110
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-12
283
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
05-03
270
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-17