AcWing 1509. 打怪
原题链接
简单
作者:
zqiceberg
,
2020-03-30 00:31:11
,
所有人可见
,
阅读 1222
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int N = 5010;
struct Guai
{
int attack;
int life;
bool operator< (const Guai& W)const
{
return life < W.life;
}
}q[N];
int ans;
int main()
{
int n, w;
cin >> n >> w;
int A, B;
cin >> A >> B;
for (int i = 0; i < n; i++) cin >> q[i].attack >> q[i].life;
sort(q, q + n);
for (int i = 0; i < n; i++)
{
if (A + B < q[i].attack) continue;
if (w - q[i].life < 0) continue;
w -= q[i].life;
ans++;
if (w == 0) break;
}
cout << ans << endl;
return 0;
}
老师是每道题都发了吗,(牛)
应该用scanf printf
厉害,但是cin cout比赛不能用的…
数据量小,都可以的。scanf更好一点
嗯嗯