-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path215B.cpp
47 lines (41 loc) · 854 Bytes
/
215B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//#include"pch.h"
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <math.h>
using namespace std;
int Min(int a, int b);
int a[100008], l[100008]; int n, m; int results[100008]; int keepDist[100005];
int main()
{
cin >> n >> m;
results[0] = 0;
int size = sizeof(keepDist) / sizeof(int);
for (int i = 0; i < sizeof(keepDist) / sizeof(int); i++) {
keepDist[i] = 0;
}
results[n + 1] = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
for (int i = n; i >= 0; i--) {
results[i] = results[i + 1];
if (keepDist[a[i]] == 0)
results[i] += 1;
keepDist[a[i]] += 1;
}
for (int i = 1; i <= m; i++) {
cin >> l[i];
}
//cout << "111111111111" << endl;
for (int i = 1; i <= m; i++) {
cout << results[l[i]] << endl;
}
//system("pause");
return 0;
}
int Min(int a, int b) {
return a > b ? b : a;
}