結果
問題 | No.182 新規性の虜 |
ユーザー |
![]() |
提出日時 | 2016-08-26 12:04:56 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 23 ms / 5,000 ms |
コード長 | 517 bytes |
コンパイル時間 | 625 ms |
コンパイル使用メモリ | 21,504 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 08:15:56 |
合計ジャッジ時間 | 2,070 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:11:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:13:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d", &a[i]); | ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <stdlib.h> int comp(const void *arg1, const void *arg2) { return *(int *)arg1 - *(int *)arg2; } int main() { int n, a[100000], cnt = 1, flag = 0, i; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &a[i]); } qsort(a, n, sizeof(int), comp); for (i = 1; i < n; i++) { if (flag == 0) { if (a[i] != a[i - 1]) cnt++; else { cnt--; flag = 1; } } else { if (a[i] != a[i - 1]) { cnt++; flag = 0; } } } printf("%d\n", cnt); return 0; }