67442023-12-18 15:54:01111Kártyajátékcpp17Accepted 30/3068ms14588 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double

#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifdef CB
	freopen("be2.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);
#endif
	int N, K;
	cin >> N >> K;
	vector<int> v(K);
	set<int> s;
	for (int i = 0; i < K; i++) {
		cin >> v[i];
		s.insert(v[i]);
	}
	int ans = 0;
	for (int i = 0; i < K; i++) {
		if (!s.erase(v[i])) {
			continue;
		}
		if (s.lower_bound(v[i]) != s.begin()) {
			ans++;
		}
		s.erase(s.begin(), s.lower_bound(v[i]));
	}
	cout << ans << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1828 KiB
2Accepted0/063ms12880 KiB
3Accepted1/13ms2072 KiB
4Accepted1/13ms2272 KiB
5Accepted1/13ms2484 KiB
6Accepted2/23ms2880 KiB
7Accepted2/23ms3088 KiB
8Accepted2/23ms3044 KiB
9Accepted1/135ms10448 KiB
10Accepted2/252ms14136 KiB
11Accepted3/354ms14100 KiB
12Accepted3/354ms14228 KiB
13Accepted1/164ms14440 KiB
14Accepted2/268ms14588 KiB
15Accepted3/361ms14460 KiB
16Accepted3/367ms14528 KiB
17Accepted3/363ms14524 KiB