結果

問題 No.865 24時間降水量
ユーザー NagisaNagisa
提出日時 2019-08-16 23:37:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,162 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 171,508 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-24 06:23:42
合計ジャッジ時間 4,914 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
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 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

struct BIT{
  vector<int> bit;
  int n;
  //1-indexed
  BIT(){init();}
  BIT(int n):n(n){init();}
  void init(){
    bit.clear();
    bit.resize(n+1,0);
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
};

signed main(){
    int N, Q, T, V, A;
    cin >> N;
    BIT bit(N+100);
    REP(i,N){
        cin >> A;
        bit.add(i+1,A);
    }
    cin >> Q;
    int ans = 0;
    REP(i,Q){
        cin >> T >> V;
        int t = V - (bit.sum(T)-bit.sum(T-1));
        bit.add(T,t);
        if (T <= 24){
            REP(j,T+1){
                ans = max(ans, bit.sum(24+j)-bit.sum(j));
            }
        }else if (N <= T+24){
            REP(j,N-T+1){
                ans = max(ans, bit.sum(T+j)-bit.sum(T+j-24));
            }
        }else{
            REP(j,48){
                ans = max(ans, bit.sum(T-24+j)-bit.sum(T+j));
            }
        }
        cout << ans << endl;
    }
  return 0;
}
0