結果

問題 No.865 24時間降水量
ユーザー shell_mugshell_mug
提出日時 2019-08-16 22:31:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 879 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 23,800 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 01:31:49
合計ジャッジ時間 2,475 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
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 AC 2 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d", a + i);
      |         ~~~~~^~~~~~~~~~~~~
main.cpp:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         scanf("%d%d", &t, &v);
      |         ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
int main(void)
{
    int n, q, a[200001] = {}, sum_all[200002] = {}, sum_24[200002] = {};
    scanf("%d", &n);
    for(int i = 0; i < n; i++) {
        scanf("%d", a + i);
        sum_all[i + 1] = sum_all[i] + a[i];
    }
    for(int i = 24; i <= n; i++) {
        sum_24[i] = sum_all[i] - sum_all[i - 24];
    }
    int max = 0;
    for(int j = 24; j <= n; j++) {
        if(max < sum_24[j]) {
            max = sum_24[j];
        }
    }
    int max_tmp = 0;
    scanf("%d", &q);
    for(int i = 0; i < q; i++) {
        int t, v;
        scanf("%d%d", &t, &v);
        int tmp = v - a[t - 1];
        for(int j = t; j < t + 24; j++) {
            if((sum_24[j] += tmp) > max_tmp) {
                max_tmp = sum_24[j];
            }
        }
        if(max_tmp > max) {
            max = max_tmp;
        }
        printf("%d\n", max);
    }
    return 0;
}
0