結果
問題 |
No.3288 Sloppy Land Grading
|
ユーザー |
![]() |
提出日時 | 2025-10-03 21:57:52 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 82 ms / 2,000 ms |
コード長 | 619 bytes |
コンパイル時間 | 586 ms |
コンパイル使用メモリ | 28,108 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-03 21:57:55 |
合計ジャッジ時間 | 2,840 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
コンパイルメッセージ
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) main.c: In function ‘solve’: main.c:21:25: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘long long int *’ [-Wformat=] 21 | scanf("%d", &num[i]); | ~^ ~~~~~~~ | | | | | long long int * | int * | %lld main.c:23:25: warning: format ‘%d’ expects argument of type ‘int *’, but argument 2 has type ‘long long int *’ [-Wformat=] 23 | scanf("%d", &cost[i]); | ~^ ~~~~~~~~ | | | | | long long int * | int * | %lld main.c:21:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d", &num[i]); | ^~~~~~~~~~~~~~~~~~~~ main.c:23:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 23 | scanf("%d", &cost[i]); | ^~~~~~~~~~~~~~~~~~~~~ main.c: In function ‘main’: main.c:34:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | scanf("%d", &t); | ^~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> long long int abs(long long int n) { if (n < 0) return -n; else return n; } long long int num[3], cost[3]; long long int cal(long long int x) { long long int res = 0, i; for (i = 0; i < 3; i++) res += cost[i] * abs(x - num[i]); return res; } void solve() { long long int i; for (i = 0; i < 3; i++) scanf("%d", &num[i]); for (i = 0; i < 3; i++) scanf("%d", &cost[i]); long long int ans = 1e18; for (i = 0; i < 3; i++) if (ans > cal(num[i])) ans = cal(num[i]); printf("%lld\n", ans); return; } int main() { int t; scanf("%d", &t); for (; t > 0; t--) solve(); return 0; }