結果
問題 | No.1447 Greedy MtSaka |
ユーザー |
![]() |
提出日時 | 2021-07-15 10:48:30 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 513 bytes |
コンパイル時間 | 415 ms |
コンパイル使用メモリ | 29,824 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-04 10:59:43 |
合計ジャッジ時間 | 975 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
main.c:2:15: warning: 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: note: 'abs' is declared in header '<stdlib.h>' 1 | #include<stdio.h> +++ |+#include <stdlib.h> 2 | long long int abs(long long int n)
ソースコード
#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; }