回答編集履歴
1
最適化
answer
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
Aiの値は高々101通りなので、
|
1
|
+
Aiの値は高々101通りなので、入力を配列flagに記録していき、初出ならcntに1加算する、といった処理で良いと思います
|
2
2
|
|
3
3
|
```c
|
4
4
|
#include <stdio.h>
|
5
5
|
|
6
6
|
int main(){
|
7
|
-
int
|
7
|
+
int n,a,cnt=0;
|
8
|
-
char
|
8
|
+
char flag[101] = {};
|
9
|
-
scanf("%d", &
|
9
|
+
scanf("%d", &n);
|
10
|
-
for (int i=0; i<
|
10
|
+
for (int i=0; i<n; i++) {
|
11
|
-
scanf("%d", &
|
11
|
+
scanf("%d", &a);
|
12
|
+
if (flag[a] == 0) cnt++;
|
12
|
-
|
13
|
+
flag[a] = 1;
|
13
14
|
}
|
14
|
-
for (int i=0; i<101; i++) sum += exists[i];
|
15
|
-
printf("%d\n",
|
15
|
+
printf("%d\n", cnt);
|
16
16
|
}
|
17
17
|
```
|