49402023-04-07 16:59:04SleepyOverlordSzínes szobák (50 pont)cpp17Elfogadva 50/5082ms7380 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

int n, c, q;
VI color;
VPII queries;

int main()
{
	cin >> n >> c >> q;
	color.RS(n + 2);
	FOR(i, 1, n) 
	{
		cin >> color[i];
	}

	queries.RS(q + 1);
	FOR(i, 1, q)
	{
		cin >> queries[i].X >> queries[i].Y;
	}

	int leftOut = 0;
	FORD(i, q, 1)
	{
		if (queries[i].X == color[leftOut] && queries[i].Y == 1)
		{
			--leftOut;
		}
		if (queries[i].X == color[leftOut + 1] && queries[i].Y == -1)
		{
			++leftOut;
		}
	}
	int rightOut = 0;
	FORD(i, q, 1)
	{
		if (queries[i].X == color[n + 1 - rightOut] && queries[i].Y == -1)
		{
			--rightOut;
		}
		if (queries[i].X == color[n - rightOut] && queries[i].Y == 1)
		{
			++rightOut;
		}
	}

	cout << leftOut + rightOut << endl;
	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1880 KiB
2Elfogadva0/082ms4500 KiB
3Elfogadva1/13ms2296 KiB
4Elfogadva1/13ms2500 KiB
5Elfogadva1/13ms2708 KiB
6Elfogadva1/13ms2932 KiB
7Elfogadva1/13ms3012 KiB
8Elfogadva1/13ms3140 KiB
9Elfogadva1/13ms3496 KiB
10Elfogadva1/14ms3584 KiB
11Elfogadva1/13ms3684 KiB
12Elfogadva1/14ms3764 KiB
13Elfogadva1/18ms3844 KiB
14Elfogadva1/14ms3784 KiB
15Elfogadva1/16ms3924 KiB
16Elfogadva1/19ms4240 KiB
17Elfogadva1/18ms4468 KiB
18Elfogadva1/18ms4420 KiB
19Elfogadva1/148ms5800 KiB
20Elfogadva1/178ms6752 KiB
21Elfogadva1/157ms5980 KiB
22Elfogadva1/164ms6332 KiB
23Elfogadva1/172ms6648 KiB
24Elfogadva1/178ms7004 KiB
25Elfogadva1/176ms7052 KiB
26Elfogadva1/178ms6968 KiB
27Elfogadva3/371ms6948 KiB
28Elfogadva3/372ms6956 KiB
29Elfogadva3/371ms6952 KiB
30Elfogadva3/372ms7120 KiB
31Elfogadva3/371ms7132 KiB
32Elfogadva3/371ms7380 KiB
33Elfogadva4/437ms6184 KiB
34Elfogadva4/461ms7004 KiB