题解:P14292 [JOI2024 预选赛 R2] 卡牌游戏 / Card Game 2
Solution
思路
考虑枚举每一张卡片并尝试将其作为合法方案中最小的卡片,设我们所枚举的卡片上的数字为
Code
#include <bits/stdc++.h>
#define Write ios::sync_with_stdio(0);
#define by cin.tie(0);
#define Na1L0n9 cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 2e5 + 10;
const int MOD = 998244353;
int n, a[N], cnt[N];
bool vis[N];
int main() {
Write by Na1L0n9
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
vis[a[i]] = 1;
}
for (int i = 1; i <= n; i++) {
if (vis[a[i] + 3] && vis[a[i] + 6]) {
cout << "Yes\n";
return 0;
}
}
cout << "No\n";
return 0;
}