結果
| 問題 |
No.1090 ソーシャルディスタンス / Social Distance
|
| ユーザー |
iiljj
|
| 提出日時 | 2020-10-07 10:34:19 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 2,000 ms |
| コード長 | 2,063 bytes |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 29,952 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 03:18:10 |
| 合計ジャッジ時間 | 1,585 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
コンパイルメッセージ
main.c: In function 'main':
main.c:6:15: warning: implicit declaration of function 'getc_unlocked' [-Wimplicit-function-declaration]
6 | tmp = getc_unlocked(stdin); \
| ^~~~~~~~~~~~~
main.c:24:5: note: in expansion of macro 'rd_int'
24 | rd_int(n, tmp);
| ^~~~~~
main.c:18:19: warning: implicit declaration of function 'putc_unlocked' [-Wimplicit-function-declaration]
18 | while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);
| ^~~~~~~~~~~~~
main.c:27:5: note: in expansion of macro 'wt_int'
27 | wt_int(prev, buf, ptr);
| ^~~~~~
ソースコード
#include <stdio.h>
// int tmp, var = 0; を先に宣言する
#define rd_int(var, tmp) \
for (;;) { \
tmp = getc_unlocked(stdin); \
if (tmp < '0' || tmp > '9') break; \
var = var * 10 + tmp - '0'; \
}
// char buf[9]; int ptr = 0; を先に宣言する
#define wt_int(var, buf, ptr) \
while (var) { \
buf[ptr++] = var % 10; \
var /= 10; \
} \
if (!ptr) buf[ptr++] = 0; \
while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);
int main() {
int n = 0, d = 0, ac = 0, prev = 0, tmp, ptr = 0;
char buf[9];
rd_int(n, tmp);
rd_int(d, tmp);
wt_int(prev, buf, ptr);
for (int i = 1; i < n; ++i) {
putc_unlocked(' ', stdout);
ptr = 0;
prev += d;
int a = 0;
rd_int(a, tmp);
ac += a;
// printf("[%d %d %d]", a, ac, prev);
if (ac > prev) prev = ac;
tmp = prev;
wt_int(tmp, buf, ptr);
// printf("[%d %d %d]\n", a, ac, prev);
}
putc_unlocked('\n', stdout);
return 0;
}
iiljj