Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
436153 沈昊坤 【C6-7】阿里巴巴与四十大盗 C++ 编译错误 0 0 MS 0 KB 490 2026-04-11 20:09:31

Tests(0/0):


#include<bits/stdc++.h> using namespace std; int main(){ int m; cin>>m; for(int i=1;i<=m;i++){ int x,n,s=0; cin>>x>>n; int a[10086],b[10086],c[10086]; for(int j=1;j<=n;j++){ cin>>a[j]>>b[j]; c[j]=1.0*b[j]/a[j]; } sort(c+1,c+n+1,<greater>(int)); for(int j=1;j<=n;j++){ if(x<=0){ break; } if(x>0&&x>=a[j]){ x-=a[j]; s+=a[j]*c[j]; }else{ s+=x*c[j]; } } cout<<fixed<<setprecision(1)<<s<<endl; } return 0; }


测评信息: