結果
問題 | No.636 硬貨の枚数2 |
ユーザー |
👑 |
提出日時 | 2019-01-29 16:57:10 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 376 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 29,056 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-10 19:22:39 |
合計ジャッジ時間 | 2,312 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 65 |
コンパイルメッセージ
main.c: In function 'main': main.c:12:3: warning: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 12 | gets(S); | ^~~~ | fgets /usr/bin/ld: /tmp/ccXuWOJp.o: in function `main': main.c:(.text.startup+0x3f): 警告: the `gets' function is dangerous and should not be used.
ソースコード
#include <stdio.h> int min(int a, int b) { return (a < b) ? a : b; } char S[10001], *s; int main(void) { int f[] = {0, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2}; int a = 0, b = 1, tmp; int x; gets(S); for (s = S; *s; ++s) { x = *s - 48; tmp = min(a + f[x], b + f[10 - x]); b = min(a + f[1 + x], b + f[9 - x]); a = tmp; } printf("%d\n", a); return 0; }