| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 440239 | 方相宜 | 【C6-7】阿里巴巴与四十大盗 | C++ | 通过 | 100 | 1 MS | 264 KB | 493 | 2026-05-10 10:10:25 |
#include<bits/stdc++.h> using namespace std; struct huangsigou{ int w,v; double k; }a[10086]; bool cmp(huangsigou x,huangsigou 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); int b=0; double s=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; }