// 2240部分背包
void px(float a[], int b[], int c[], int n)
{
for (int j = 1; j < n; j)
{
int o = 0;
for (int i = 0; i < n - j; i)
{
if (a[i] > a[i + 1])
{
float d = a[i];
int e = b[i];
int f = c[i];
a[i] = a[i + 1];
b[i] = b[i + 1];
c[i] = c[i + 1];
a[i + 1] = d;
b[i + 1] = e;
c[i + 1] = f;
o = 1;
}
}
if (o == 0)
break;
}
}
int main()
{
int N, T;
scanf(“%d %d”, &N, &T);
int m[100] = { 0 };
int v[100] = { 0 };
float w[100] = { 0 };
int a = N;
int worth = 0;
while (N–)
{
scanf(“%d %d”, &m[N], &v[N]);
}
for (int i = 0; i < a; i++)
{
w[i] = (float)v[i] / m[i];
}
px(w, m, v, a);
a–;
while (T > 0)
{
if (T >= m[a])
{
T = T - m[a];
worth += v[a];
a--;
}
else
{
worth = worth + (T * w[a]);
T = 0;
}
}
printf("%d\n", worth);
return 0;
}