結果

問題 No.1090 ソーシャルディスタンス / Social Distance
ユーザー iiljjiiljj
提出日時 2020-10-07 10:24:13
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,970 bytes
コンパイル時間 122 ms
コンパイル使用メモリ 29,008 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-27 09:10:09
合計ジャッジ時間 3,328 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘main’ 内:
main.c:6:15: 警告: 関数 ‘getc_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
    6 |         tmp = getc_unlocked(stdin);                                                                                    \
      |               ^~~~~~~~~~~~~
main.c:24:5: 備考: in expansion of macro ‘rd_int’
   24 |     rd_int(n, tmp);
      |     ^~~~~~
main.c:18:19: 警告: 関数 ‘putc_unlocked’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   18 |     while (ptr--) putc_unlocked(buf[ptr] + '0', stdout);
      |                   ^~~~~~~~~~~~~
main.c:27:5: 備考: in expansion of macro ‘wt_int’
   27 |     wt_int(prev, buf, ptr);
      |     ^~~~~~

ソースコード

diff #

#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);
    putc_unlocked('\n', stdout);
    for (int i = 1; i < n; ++i) {
        ptr = 0;
        prev += d;
        int a = 0;
        rd_int(a, tmp);
        ac += a;
        if (ac > prev) prev = ac;
        tmp = prev;
        wt_int(tmp, buf, ptr);
        putc_unlocked('\n', stdout);
    }
    return 0;
}
0