Algorithm


Problem Name: beecrowd | 2783

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/2783

Cup Stickers

 

By OBI BR Brasil

Timelimit: 1

In Soccer World Cup year, the official album of cards is always a great success among children and also among adults. For those who do not know, the album contains spaces numbered from 1 to N to paste the cards; each sticker, also numbered from 1 to N, is a small photo of a player from one of the selections that will play the World Cup. The goal is to paste all the cards in the respective spaces in the album, in order to complete the album (that is, leave no space without the corresponding sticker).

Some stickers are stamped and are rarer, harder to get. The stickers are sold in closed envelopes, so the buyer is not buying the stickers he is buying, and may happen to buy a sticker that has already pasted on the album.

To help users, the company that sells the album and stickers wants to create an application that allows them to easily manage the missing pieces to complete the album and is asking for their help.

Given the total number of spaces and stickers in the album (N), the list of stamped cards and a list of already purchased cards (which may contain repeated stickers), your task is to determine how many stamped stickers are missing to complete the album.

 

Input

 

The first line contains three integers N (1 ≤ N ≤ 100), C (1 ≤ C ≤ N / 2) and M (1 ≤ M ≤ 300) respectively indicating the number of cards (and spaces) of the album, the number of stamps stamped on the album and the number of cards already purchased. The second line contains C distinct integers Xi indicating the stamps stamped on the album. The third line contains M integers Yi (1 ≤ Xi, YiN) indicating the cards already purchased.

 

Output

 

Your program should to produce an integer representing the number of the sitckers stamped that are missing to complete the album

 

 

 

Input Samples Output Samples

10 2 5

4 7

7 1 2 8 3

1

 

 

 

10 2 6

4 7

7 1 8 4 9 3

0

 

 

 

8 4 10

2 4 6 8

3 1 1 5 1 1 7 7 1 1

4

 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, c, m, s=0;
    cin >> n >> c >> m;
    vector<int>v(c), v1(m);
    for (int i=0; i  <  c; ++i)
        cin >> v[i];
    for (int i = 0; i  <  m; ++i)
        cin >> v1[i];

    for (int i=0; i  <  c; ++i)
    {
        vector<int>::iterator it;
        it=find(v1.begin(), v1.end(), v[i]);
        if (it==v1.end())
            s++;
    }
    cout << s << endl;
    return 0;
}

Copy The Code & Try With Live Editor

#2 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
let [a, b, c] = lines.shift().split(" ");
let carimbadas = lines.shift().trim().split(" ");
let cards = lines.shift().split(" ");
let deck = [];
let cont = 0;

for(let i = 0; i  <  parseInt(c); i++){
  deck.push(cards[i]);
}

const newDeck = [...new Set(deck)];

for(let i = 0; i  <  parseInt(b); i++){
  for(let j = 0; j  <  newDeck.length; j++){
    if(newDeck[j] === carimbadas[i]){
      cont++
    }
  }
}

console.log(parseInt(b) - cont);
Copy The Code & Try With Live Editor

#3 Code Example with Python Programming

Code - Python Programming


e = input()
a = [int(x) for x in str(input()).split()]
l = [int(x) for x in str(input()).split()]
q = 0
for i in a:
    if not i in l: q += 1
print(q)
Copy The Code & Try With Live Editor
Advertisements

Demonstration


Previous
#2782 Beecrowd Online Judge Solution 2782 Stepladder Solution in C, C++, Java, Js and Python
Next
#2785 Beecrowd Online Judge Solution 2785 Pyramid Solution in C, C++, Java, Js and Python