結果

問題 No.182 新規性の虜
ユーザー くれちーくれちー
提出日時 2016-08-26 11:38:24
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 613 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 8,480 KB
最終ジャッジ日時 2024-04-25 16:55:30
合計ジャッジ時間 11,556 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 0 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,948 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 4,610 ms
6,944 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
evil01.txt -- -
evil02.txt -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:20:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         scanf("%d", &n);
      |         ^~~~~~~~~~~~~~~
main.c:22:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |                 scanf("%d", &a[i]);
      |                 ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

void sort(int arg[], int n) {
	int temp, i, j;

	for (i = 0; i < n - 1; i++) {
		for (j = n - 1; j > i; j--) {
			if (arg[j] < arg[j - 1]) {
				temp = arg[j];
				arg[j] = arg[j - 1];
				arg[j - 1] = temp;
			}
		}
	}
}

int main() {
	int n, a[100000], cnt = 1, flag = 0, i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	
	sort(a, n);
	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;
}
0