제출 #1116111

#제출 시각아이디문제언어결과실행 시간메모리
1116111staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
131 ms7240 KiB
#include <bits/stdc++.h> using namespace std; int n,q,s,t; long long tr[400002]; void add(int l, int r, int v) { l+=n+1; r+=n+1; tr[l]+=v; if(r!=l) tr[r]+=v; while(l/2 != r/2) { if(l%2 == 0) tr[l+1] +=v; if(r%2 == 1) tr[r-1] +=v; l/=2;r/=2; } } long long check(int p) { long long ans = 0; p+=n+1; while(p > 0) { ans+=tr[p]; p/=2; } return ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>q>>s>>t; long long ans= 0; for(int i = 0;i<n+1;i++) { long long a; cin>>a; add(i,i,a); if(i!= 0) { long long c = check(i-1); if(a > c) { ans -= (a-c)*s; } else { ans+= (c-a)*t; } } } for(int i = 0;i<q;i++) { int l,r,x; cin>>l>>r>>x; long long a = check(l-1); long long b =check(l); long long f,g; if(r!=n) { f = check(r); g = check(r+1); } add(l,r,x); long long c = check(l); long long h = check(r); ans += (min(a,b) - min(a,c))*t; ans += (max(a,b) - max(a,c))*s; if(r!= n) { ans-=(min(g,f) - min(g,h))*s; ans-=(max(g,f) - max(g,h))*t; } cout<<ans<<"\n"; } }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:62:21: warning: 'g' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |         long long f,g;
      |                     ^
foehn_phenomena.cpp:62:19: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |         long long f,g;
      |                   ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...