제출 #422335

#제출 시각아이디문제언어결과실행 시간메모리
422335jlallas384Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
772 ms11480 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; struct FT{ vector<ll> ft; int n; FT(int n) : n(n),ft(n+1){}; void upd(int idx,int val){ for(; idx <= n; idx += idx & -idx){ ft[idx] += val; } } ll qry(int idx){ ll sum = 0; for(; idx > 0; idx -= idx & -idx){ sum += ft[idx]; } return sum; } }; int main(){ int n,q,s,t; cin >> n >> q >> s >> t; auto f = [&](ll a,ll b){ if(a < b) return (b - a) * s * -1; return (a - b) * t; }; FT ft(n); int prv = 0; ll ans = 0; for(int i = 0; i <= n; i++){ int x; cin >> x; if(i){ ans += f(prv,x); ft.upd(i,x); ft.upd(i + 1,-x); } prv = x; } while(q--){ int l,r,x; cin >> l >> r >> x; ans -= f(ft.qry(l-1),ft.qry(l)); if(r != n){ ans -= f(ft.qry(r),ft.qry(r+1)); } ft.upd(l,x); ft.upd(r + 1,-x); ans += f(ft.qry(l-1),ft.qry(l)); if(r != n){ ans += f(ft.qry(r),ft.qry(r+1)); } cout << ans << '\n'; } }

컴파일 시 표준 에러 (stderr) 메시지

foehn_phenomena.cpp: In constructor 'FT::FT(int)':
foehn_phenomena.cpp:7:9: warning: 'FT::n' will be initialized after [-Wreorder]
    7 |     int n;
      |         ^
foehn_phenomena.cpp:6:16: warning:   'std::vector<long long int> FT::ft' [-Wreorder]
    6 |     vector<ll> ft;
      |                ^~
foehn_phenomena.cpp:8:5: warning:   when initialized here [-Wreorder]
    8 |     FT(int n) : n(n),ft(n+1){};
      |     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...