社区讨论

求调

P12860[NERC 2020 Online] Kate' s 2021 Celebration参与者 1已保存回复 0

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
0 条
当前快照
1 份
快照标识符
@mimp44h8
此快照首次捕获于
2025/12/01 13:15
3 个月前
此快照最后确认于
2025/12/03 18:20
3 个月前
查看原帖
CPP
#include <bits/stdc++.h> 
using namespace std;

int n, p, i, ans, money = 1e5;
string s;

int check (string s) {
	int cnt1 = 0, cnt0 = 0, cnt2 = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') cnt0++;
		if (s[i] == '1') cnt1++;
		if (s[i] == '2') cnt2++;
	}
	if (cnt0 > 0 && cnt1 > 0 && cnt2 > 1) return 1;
	return 0;
}

int main() {
    cin >> n;
    while (n--) {
    	i++;
    	cin >> p >> s;
    	if (check(s) && money > p) {
    		ans = i;
    		money = p;
		}
	}
	cout << ans;
    return 0;
}

回复

0 条回复,欢迎继续交流。

正在加载回复...