94552024-02-21 21:14:59Vkrisztian01Színes szobák (50 pont)cpp11Time limit exceeded 24/50386ms11200 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>>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/04ms7328 KiB
2Accepted0/093ms9384 KiB
3Accepted1/16ms7600 KiB
4Accepted1/17ms7832 KiB
5Accepted1/16ms8120 KiB
6Accepted1/16ms7996 KiB
7Accepted1/16ms8268 KiB
8Accepted1/16ms8476 KiB
9Accepted1/16ms8692 KiB
10Accepted1/18ms8920 KiB
11Accepted1/16ms8792 KiB
12Accepted1/18ms9052 KiB
13Accepted1/150ms9132 KiB
14Accepted1/120ms9132 KiB
15Accepted1/124ms9412 KiB
16Accepted1/175ms9440 KiB
17Accepted1/193ms9312 KiB
18Accepted1/190ms9212 KiB
19Accepted1/159ms10952 KiB
20Accepted1/192ms10952 KiB
21Accepted1/171ms11084 KiB
22Accepted1/175ms10952 KiB
23Accepted1/186ms10952 KiB
24Accepted1/192ms11056 KiB
25Accepted1/190ms10952 KiB
26Accepted1/192ms11200 KiB
27Time limit exceeded0/3358ms7124 KiB
28Time limit exceeded0/3370ms7052 KiB
29Time limit exceeded0/3381ms7036 KiB
30Time limit exceeded0/3370ms7268 KiB
31Time limit exceeded0/3374ms7072 KiB
32Time limit exceeded0/3386ms7072 KiB
33Time limit exceeded0/4370ms6456 KiB
34Time limit exceeded0/4352ms6416 KiB