55672023-07-28 09:26:331478Színes szobák (50 pont)cpp17Accepted 50/5082ms24808 KiB
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
int main()
{
    //ifstream cin("in.txt");
    int n, k, m;
    cin >> n >> k >> m;
    vector<int> roomColors(n + 2);
    for(int i = 1; i <= n; i++){
        cin >> roomColors[i];
    }
    vector<pair<int, int>> orders(m + 1);
    for(int i = m; i >= 1; i--){
        cin >> orders[i].first >> orders[i].second;
    }
    int l = 0, r = n + 1;
    for(int i = 1; i <= m; i++){
        if(orders[i].second == -1){ 
            if(roomColors[l + 1] == orders[i].first){
                l++;
            }
            if(roomColors[r] == orders[i].first){
                r++;
            }
        }

        if(orders[i].second == 1){ 
            if(roomColors[l] == orders[i].first){
                l--;
            }
            if(roomColors[r - 1] == orders[i].first){
                r--;
            }
        }
    }

    cout << l + n - r + 1;



    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms2084 KiB
2Accepted0/082ms5888 KiB
3Accepted1/13ms3732 KiB
4Accepted1/13ms3852 KiB
5Accepted1/13ms4096 KiB
6Accepted1/13ms4332 KiB
7Accepted1/13ms4440 KiB
8Accepted1/13ms4816 KiB
9Accepted1/13ms5040 KiB
10Accepted1/14ms5140 KiB
11Accepted1/13ms5236 KiB
12Accepted1/14ms5616 KiB
13Accepted1/18ms6060 KiB
14Accepted1/14ms5928 KiB
15Accepted1/16ms5860 KiB
16Accepted1/18ms6088 KiB
17Accepted1/18ms6184 KiB
18Accepted1/18ms6276 KiB
19Accepted1/150ms8156 KiB
20Accepted1/179ms10596 KiB
21Accepted1/159ms10876 KiB
22Accepted1/164ms12276 KiB
23Accepted1/174ms13612 KiB
24Accepted1/179ms15452 KiB
25Accepted1/179ms16492 KiB
26Accepted1/179ms17804 KiB
27Accepted3/372ms18824 KiB
28Accepted3/372ms19724 KiB
29Accepted3/371ms20608 KiB
30Accepted3/371ms21704 KiB
31Accepted3/371ms22600 KiB
32Accepted3/372ms23600 KiB
33Accepted4/437ms23056 KiB
34Accepted4/461ms24808 KiB