結果

問題 No.1447 Greedy MtSaka
ユーザー pengin_2000pengin_2000
提出日時 2021-07-15 10:48:30
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 28,356 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 16:03:09
合計ジャッジ時間 1,872 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 0 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 0 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 0 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 0 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:15: 警告: conflicting types for built-in function ‘abs’; expected ‘int(int)’ [-Wbuiltin-declaration-mismatch]
    2 | long long int abs(long long int n)
      |               ^~~
main.c:2:1: 備考: ‘abs’ is declared in header ‘<stdlib.h>’
    1 | #include<stdio.h>
  +++ |+#include <stdlib.h>
    2 | long long int abs(long long int n)

ソースコード

diff #

#include<stdio.h>
long long int abs(long long int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
long long int s(long long int x1, long long int y1, long long int x2, long long int y2)
{
	return abs(x1 * y2 - x2 * y1);
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	long long int x[33], y[33];
	for (i = 0; i < n; i++)
		scanf("%lld %lld", &x[i], &y[i]);
	long long int ans = 0;
	for (i = 1; i < n - 1; i++)
		ans += s(x[i] - x[0], y[i] - y[0], x[i + 1] - x[0], y[i + 1] - y[0]);
	printf("%lld\n", ans);
	return 0;
}
0