55672023-07-28 09:26:331478Színes szobák (50 pont)cpp17Elfogadva 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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms2084 KiB
2Elfogadva0/082ms5888 KiB
3Elfogadva1/13ms3732 KiB
4Elfogadva1/13ms3852 KiB
5Elfogadva1/13ms4096 KiB
6Elfogadva1/13ms4332 KiB
7Elfogadva1/13ms4440 KiB
8Elfogadva1/13ms4816 KiB
9Elfogadva1/13ms5040 KiB
10Elfogadva1/14ms5140 KiB
11Elfogadva1/13ms5236 KiB
12Elfogadva1/14ms5616 KiB
13Elfogadva1/18ms6060 KiB
14Elfogadva1/14ms5928 KiB
15Elfogadva1/16ms5860 KiB
16Elfogadva1/18ms6088 KiB
17Elfogadva1/18ms6184 KiB
18Elfogadva1/18ms6276 KiB
19Elfogadva1/150ms8156 KiB
20Elfogadva1/179ms10596 KiB
21Elfogadva1/159ms10876 KiB
22Elfogadva1/164ms12276 KiB
23Elfogadva1/174ms13612 KiB
24Elfogadva1/179ms15452 KiB
25Elfogadva1/179ms16492 KiB
26Elfogadva1/179ms17804 KiB
27Elfogadva3/372ms18824 KiB
28Elfogadva3/372ms19724 KiB
29Elfogadva3/371ms20608 KiB
30Elfogadva3/371ms21704 KiB
31Elfogadva3/371ms22600 KiB
32Elfogadva3/372ms23600 KiB
33Elfogadva4/437ms23056 KiB
34Elfogadva4/461ms24808 KiB