結果
問題 |
No.182 新規性の虜
|
ユーザー |
![]() |
提出日時 | 2019-02-23 00:37:26 |
言語 | C (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 731 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 29,696 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-26 08:21:40 |
合計ジャッジ時間 | 3,963 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 2 |
other | AC * 3 RE * 24 |
ソースコード
#include <stdio.h> #include <stdlib.h> #define _CRT_SECURE_NO_WARNINGS 1 int asc(const void *a, const void *b) { return *(int *)a - *(int *)b; } int main(void) { int N = 0; int *edgh = NULL; int *p = NULL; int cnt = 0; int sinkisei = 0; scanf("%d", &N); edgh = (int *)malloc(N); //終端位置をNULLにする p = edgh + N; *p = -1; p = edgh; for (int i = 0; i < N; i++) { scanf("%d", p); p++; } //昇順にソートする qsort(edgh, N, sizeof(int), asc); p = edgh; while (*p != -1) { if (*p == *(p+1) ) { cnt++; } if (*p != *(p+1) && cnt == 0) { sinkisei += 1; } if (*p != *(p + 1) && cnt > 0) { cnt = 0; } p++; } printf("%d\n", sinkisei); free(edgh); return 0; }