跳到正文

题解

改编

_O_v_O_约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年12月12日
收录
2025年12月12日
更新
2026年10月29日
篇幅
约 1 分钟
获赞
4
题目
P13277

版本

  1. v1当前

首先,对于一题的质量,我们使用 if 语句判断一道题最终的质量即可。

接着,我们使用 ans=max(ans,a); 来判断质量最大值。

C++
#include<bits/stdc++.h>
using namespace std;

int n,k1,k2,ans=-114514;

signed main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n>>k1>>k2;
	for(int i=1,a,x,y;i<=n;i++){
		cin>>a>>x>>y;
		if(x&&y) continue;
		if(x) a-=k1;
		if(y) a-=k2;
		if(a<0) continue;
		ans=max(ans,a);
	}
    if(ans==-114514) cout<<-1;
	else cout<<ans;
	return 0;
}
原文
存档评论16 条抓取于