记录编号 |
385406 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[HAOI 2013]花卉节 |
最终得分 |
100 |
用户昵称 |
kZime |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.170 s |
提交时间 |
2017-03-21 11:12:06 |
内存使用 |
15.57 MiB |
显示代码纯文本
/*kZime*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <algorithm>
#define MAXN 1000000
#define ll long long
using namespace std;
inline ll read() {
ll k = 0, f = 1; char c = getchar();
for(; !isdigit(c); c = getchar())if(c == '-') f = -1;
for(; isdigit(c); c = getchar()) k = k * 10 + c - '0';
return k * f;
}
/*-----------------------------------------------------------------------------*/
struct f{
ll p, w;
}fl[MAXN];
ll n, m;
bool cmp(f a, f b) {
return a.w < b.w;
}
int main() {
#ifndef MYLAB
freopen("haoi13_t2.in", "r", stdin);
freopen("haoi13_t2.out", "w", stdout);
#else
freopen("in.txt", "r", stdin);
#endif
n = read();
m = read();
for(ll i = 0; i < n; i++) {
fl[i].w = read();
fl[i].p = read();
}
sort(fl, fl + n, cmp);
ll i = 0, ans = 0;
while(i < n) {
ll temp = m / fl[i].w;
if(temp > fl[i].p) {
ans += fl[i].p;
m -= fl[i].p * fl[i].w;
i++;
}
else {
ans += temp;
break;
}
}
printf("%lld", ans);
return 0;
}