标签:com blog class div code size log c t sp string
1 3 15 5 10 2 8 3 9
65
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 |
#include<iostream>#include<cstring>#include<cstdio>#include <memory> #include<queue>#include<algorithm>using
namespace std;struct
bag{ int
v; int
w;};bag b[11];bool
cmp(bag a,bag b){ return
a.v>b.v;}int
main(int
argc, char* argv[]){ int
n; scanf("%d", &n); while(n--) { int
s,m,i,sum; sum=0; memset(b,0,sizeof(b)); scanf("%d%d",&s,&m); for(i=0;i<s;i++) scanf("%d%d",&b[i].v,&b[i].w); sort(b,b+s,cmp); for(i=0;i<s;i++) { if(m-b[i].w>=0) {m-=b[i].w;sum+=b[i].v*b[i].w;} else
{sum+=b[i].v*m; break;} } printf("%d\n",sum); } return
0;} |
标签:com blog class div code size log c t sp string
原文地址:http://www.cnblogs.com/52Cyan/p/3699571.html