49412023-04-07 17:03:41SleepyOverlordSzínes szobák (50 pont)cpp17Elfogadva 50/5082ms6888 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, rightOut = 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;
	}
	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/03ms1876 KiB
2Elfogadva0/082ms4508 KiB
3Elfogadva1/13ms2292 KiB
4Elfogadva1/13ms2652 KiB
5Elfogadva1/13ms2728 KiB
6Elfogadva1/13ms2760 KiB
7Elfogadva1/13ms2964 KiB
8Elfogadva1/13ms3196 KiB
9Elfogadva1/13ms3260 KiB
10Elfogadva1/14ms3404 KiB
11Elfogadva1/13ms3472 KiB
12Elfogadva1/14ms3608 KiB
13Elfogadva1/18ms3776 KiB
14Elfogadva1/14ms3716 KiB
15Elfogadva1/16ms3724 KiB
16Elfogadva1/18ms3776 KiB
17Elfogadva1/18ms3788 KiB
18Elfogadva1/18ms3784 KiB
19Elfogadva1/148ms5020 KiB
20Elfogadva1/178ms6096 KiB
21Elfogadva1/157ms5336 KiB
22Elfogadva1/163ms5688 KiB
23Elfogadva1/174ms5816 KiB
24Elfogadva1/179ms6212 KiB
25Elfogadva1/178ms6204 KiB
26Elfogadva1/176ms6204 KiB
27Elfogadva3/371ms6544 KiB
28Elfogadva3/372ms6752 KiB
29Elfogadva3/372ms6752 KiB
30Elfogadva3/371ms6828 KiB
31Elfogadva3/371ms6880 KiB
32Elfogadva3/371ms6888 KiB
33Elfogadva4/437ms5404 KiB
34Elfogadva4/461ms6580 KiB