51402023-04-20 03:02:26SleepyOverlordKártyajátékcpp17Elfogadva 30/30119ms14648 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

LL n;
int k;
VLL a;
set <LL> b;

int main()
{
	cin >> n >> k;
	a.RS(k + 1);
	FOR(i, 1, k)
	{
		cin >> a[i];
		b.INS(a[i]);
	}

	int sol = 0;
	FOR(i, 1, k)
	{
		auto it = b.find(a[i]);
		if (!b.empty() && it != b.EN && it != b.BG) ++sol;
		while (!b.empty() && *(b.BG) <= a[i]) b.erase(b.BG);
	}

	cout << sol;

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base30/30
1Elfogadva0/03ms1876 KiB
2Elfogadva0/0118ms12956 KiB
3Elfogadva1/13ms2328 KiB
4Elfogadva1/13ms2364 KiB
5Elfogadva1/13ms2612 KiB
6Elfogadva2/23ms2996 KiB
7Elfogadva2/23ms3208 KiB
8Elfogadva2/23ms3164 KiB
9Elfogadva1/152ms10308 KiB
10Elfogadva2/279ms13832 KiB
11Elfogadva3/375ms14260 KiB
12Elfogadva3/379ms14472 KiB
13Elfogadva1/1118ms14388 KiB
14Elfogadva2/2116ms14300 KiB
15Elfogadva3/3115ms14424 KiB
16Elfogadva3/3119ms14516 KiB
17Elfogadva3/3115ms14648 KiB