Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
436187 任虞昊 【C6-7】阿里巴巴与四十大盗 C++ 通过 100 1 MS 264 KB 474 2026-04-11 20:31:22

Tests(1/1):


#include<bits/stdc++.h> using namespace std; struct hsb{ int w,v; double k; }a[10086]; bool cmp(hsb x,hsb y){ return x.k>y.k ; } int main(){ int n,c; cin>>n>>c; for(int i=1;i<=n;i++){ cin>>a[i].w>>a[i].v; a[i].k=1.0*a[i].v/a[i].w; } sort(a+1,a+n+1,cmp); double s=0; int b=0; while(c>0){ b++; if(c>=a[b].w){ c=c-a[b].w; s=s+a[b].v; }else{ s+=c*a[b].k; c=0; } } cout<<fixed<<setprecision(1)<<s; return 0; return 0; }


测评信息: