結果

問題 No.865 24時間降水量
ユーザー i_am_nicolen_22i_am_nicolen_22
提出日時 2019-08-17 00:42:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,810 bytes
コンパイル時間 1,455 ms
コンパイル使用メモリ 165,056 KB
実行使用メモリ 12,344 KB
最終ジャッジ日時 2023-10-24 14:01:56
合計ジャッジ時間 3,306 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

int a[200010];
int t[200010],v[200010];
signed main(){
    int n,q;
    cin>>n;
    REP(i,n) cin>>a[i];
    cin>>q;
    REP(i,q) {
        cin>>t[i]>>v[i];
        t[i]--;
    }
    vector<pair<int,int>>w;
    ll sum=0;
    for (int i = 0; i < n; i++)
    {   if(i<23) sum+=a[i];
        else{
            sum+=a[i];
            w.push_back({sum,i-23});
            sum-=a[i-23];
        }
    }
  //  show(w);
 //   cerr<<"a"<<endl;
    int pre_max=0;
    for (int i = 0; i < w.size(); i++)
    {
        if(pre_max<w[i].first) pre_max=w[i].first;
    }
  //  cerr<<"b"<<endl;
    for (int i = 0; i < q; i++)
    {
        //a[t[i]]=v[i];
     //   cerr<<v[i]-a[t[i]]<<endl;
        for(int j=t[i]-24;j<t[i]+24;j++){
            if(j<0 || j>=w.size()) continue;
            if(w[j].second<t[i]-24 || w[j].second>t[i]) continue;
            w[j].first+=v[i]-a[t[i]];
          //  if(j==w[j].first) break;
            if(pre_max<w[j].first) pre_max=w[j].first;
        }
        a[t[i]]=v[i];
    //    cerr<<t[i]<<endl;
        //show(w);
        cout<<pre_max<<"\n";
        
    }
    

    
   return 0;
}
0