哈哈哈
2025-01-28 03:05:12
发布于:广东
5阅读
0回复
0点赞
哈!?
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
vector<bool> board(m + 1, false);
for (int i = 0; i < n; ++i) {
int ai;
cin >> ai;
if (!board[ai]) board[ai] = true;
else if (ai + 1 <= m && !board[ai + 1]) board[ai + 1] = true; }
int count = 0;
for (bool hasPiece : board) if (hasPiece) ++count;
cout << count << endl;
return 0; }
乐观点
快乐点
这里空空如也
有帮助,赞一个