제출 #209248

#제출 시각아이디문제언어결과실행 시간메모리
209248jzhFoehn Phenomena (JOI17_foehn_phenomena)C++14
10 / 100
171 ms7288 KiB
#include <bits/stdc++.h> #pragma O3 using namespace std; typedef long long ll; ll ft[2000005]={0}; ll ls(ll x) { return (x & (-x)); } ll query(ll p) { ll sum = 0; for(; p; p -= ls(p)) sum += ft[p]; return sum; } void update(ll x, ll y, ll v) { for(; x < 2000005; x += ls(x)) ft[x] += v; y++; for(; y < 2000005; y += ls(x)) ft[y] -= v;} int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll n,q,i,s,t,i1,x,y,w,sum=0,xi,yi,xf,yf,xii,yii; cin>>n>>q>>s>>t; ll arr[n+1]; for (i=0;i<=n;i++){ cin>>arr[i]; if (i>0)update(i,i,arr[i]); } for (i=1;i<=n;i++){ if (arr[i]>arr[i-1])sum-=s*(arr[i]-arr[i-1]); else sum+=t*(arr[i-1]-arr[i]); } //cout<<sum<<'\n'; while (q--){ cin>>x>>y>>w; xi=query(x); yi=query(x-1); xii=query(y+1); yii=query(y); //cout<<xi<<' '<<yi<<' '<<xii<<' '<<yii<<'\n'; update(x,y,w); xf=query(x); yf=query(x-1); //cout<<xf<<' '<<yf<<' '; if (xi>yi){ sum+=s*(xi-yi); } else { sum-=t*(yi-xi); } if (xf<=yf){ sum+=t*(yf-xf); } else { sum-=s*(xf-yf); } xi=xii; yi=yii; xf=query(y+1); yf=query(y); //cout<<xf<<' '<<yf<<'\n'; if (y==n){} else { if (xi>yi){ sum+=s*(xi-yi); } else { sum-=t*(yi-xi); } if (xf<=yf){ sum+=t*(yf-xf); } else { sum-=s*(xf-yf); } } cout<<sum<<'\n'; } }

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

foehn_phenomena.cpp:2:0: warning: ignoring #pragma O3  [-Wunknown-pragmas]
 #pragma O3
 
foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:22:18: warning: unused variable 'i1' [-Wunused-variable]
     ll n,q,i,s,t,i1,x,y,w,sum=0,xi,yi,xf,yf,xii,yii;
                  ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...