94562024-02-21 21:15:59Vkrisztian01Színes szobák (50 pont)cpp11Time limit exceeded 24/50377ms11884 KiB
#include <iostream>
#include<vector>

using namespace std;

int n,k,m,a,b;
vector<int>rooms(1e5 +3,1);
vector<vector<int> >color(1e5 +3);

int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n>>k>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        color[a].push_back(i);
    }
    while(m--)
    {
        cin>>a>>b;
        if(b==1)
        {
            for(int i=color[a].size()-1;i>=0;i--)
            {
                rooms[color[a][i]+1]+=rooms[color[a][i]];
                rooms[color[a][i]]=0;
            }
        }
        else
        {
            for(int i=0;i<color[a].size();i++)
            {
                rooms[color[a][i]-1]+=rooms[color[a][i]];
                rooms[color[a][i]]=0;
            }
        }
    }
    cout<<rooms[0]+rooms[n+1]-2;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base24/50
1Accepted0/04ms7072 KiB
2Accepted0/043ms9112 KiB
3Accepted1/16ms7612 KiB
4Accepted1/16ms7768 KiB
5Accepted1/14ms8040 KiB
6Accepted1/14ms8252 KiB
7Accepted1/14ms8148 KiB
8Accepted1/16ms8400 KiB
9Accepted1/16ms8616 KiB
10Accepted1/18ms8888 KiB
11Accepted1/16ms8840 KiB
12Accepted1/18ms8860 KiB
13Accepted1/148ms8972 KiB
14Accepted1/118ms8908 KiB
15Accepted1/121ms9164 KiB
16Accepted1/171ms9580 KiB
17Accepted1/187ms9472 KiB
18Accepted1/187ms9408 KiB
19Accepted1/129ms11280 KiB
20Accepted1/145ms11420 KiB
21Accepted1/134ms11552 KiB
22Accepted1/137ms11808 KiB
23Accepted1/143ms11704 KiB
24Accepted1/146ms11864 KiB
25Accepted1/146ms11856 KiB
26Accepted1/145ms11884 KiB
27Time limit exceeded0/3377ms7892 KiB
28Time limit exceeded0/3375ms7832 KiB
29Time limit exceeded0/3358ms7888 KiB
30Time limit exceeded0/3367ms8084 KiB
31Time limit exceeded0/3375ms8076 KiB
32Time limit exceeded0/3347ms8140 KiB
33Time limit exceeded0/4365ms11624 KiB
34Time limit exceeded0/4365ms7532 KiB