acgo题库
  • 首页
  • 题库
  • 学习
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情提交记录(0)
  • 秒了

    userId_undefined

    AAA驾校教练杨教练(即将出狱)

    出道萌新字符串·魔法使模拟·模拟练习生循环·循环打卡人递归·套娃学徒贪心·贪心尝试者
    60阅读
    1回复
    0点赞
  • 题解

    #include<bits/stdc++.h> using namespace std; struct Apple{ int height,qe; }; bool rt(const Apple& a, const Apple& b) { return a.qe<b.qe; } int mx(int n,int s,int a,int b,vector<Apple>& apples) { sort(apples.begin(), apples.end(), rt); int count=0; for(const auto& apple : apples) { if(s>=apple.qe) { if (apple.height<=b || (apple.height-a)<=b) { s-=apple.qe; count++; } } else{ break; } } return count; } int main() { int n, s, a, b; cin>>n>>s>>a>>b; vector<Apple>apples(n); for (int i=0;i<n;i++) { cin>>apples[i].height>>apples[i].qe; } cout<<mx(n, s, a, b, apples); return 0; }

    userId_undefined

    复仇者_黑客_ZDZL

    出道萌新
    23阅读
    0回复
    0点赞
  • 抄

    #include <bits/stdc++.h> using namespace std; struct Apple { int height, qe; }; bool rt(const Apple& a, const Apple& b) { return a.qe < b.qe; } int mx(int n, int s, int a, int b, vector<Apple>& apples) { sort(apples.begin(), apples.end(), rt); } int main() { int n, s, a, b; cin >> n >> s >> a >> b; vector<Apple> apples(n); for (int i = 0; i < n; ++i) { cin >> apples[i].height >> apples[i].qe; } cout << mx(n, s, a, b, apples) << endl; return 0; }

    userId_undefined

    塔塔

    I/O·IO入门者倔强青铜分支·分支解题者
    9阅读
    0回复
    0点赞
暂无数据

提交答案之后,这里将显示提交结果~

首页