제출 #242080

#제출 시각아이디문제언어결과실행 시간메모리
242080michaoFoehn Phenomena (JOI17_foehn_phenomena)C++14
0 / 100
163 ms15352 KiB
#include <bits/stdc++.h> //#define ll long long int #define int long long #define mp make_pair #define pb push_back #define ld long double #define pii pair<int,int> #define sz(x) (int)x.size() #define piii pair<pii,pii> #define precise cout<<fixed<<setprecision(10) #define st first #define nd second #define ins insert #define vi vector<int> #define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; int n,q,s,t; int ans=0; const int MAX=1<<18; int tree[2*MAX]; int tab[MAX]; int dp[MAX]; void update(int u,int v,int c) { for (u+=MAX,v+=MAX;u<v;u>>=1,v>>=1) { if (u&1)tree[u++]+=c; if (v&1)tree[--v]+=c; } } int query(int u) { int sum=u; for (u+=MAX;u>0;u>>1)sum+=tree[u]; return sum; } int32_t main() { BOOST; cin>>n>>q>>s>>t; for (int i=0;i<=n;i++)cin>>tab[i],update(i,i+1,tab[i]); dp[0]=0; for (int i=1;i<=n;i++) { if (tab[i]>tab[i-1])dp[i]=dp[i-1]-s*(tab[i]-tab[i-1]); else dp[i]=dp[i-1]+t*(tab[i-1]-tab[i]); //cout<<"TERAZ "<<i<<" "<<dp[i]<<"\n"; } ans=dp[n]; for (int z=0;z<q;z++) { int l,r,c; cin>>l>>r>>c; update(l,r+1,c); ans+=(r-l+1)*c; cout<<ans<<"\n"; } return 0; }

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

foehn_phenomena.cpp: In function 'long long int query(long long int)':
foehn_phenomena.cpp:35:19: warning: for increment expression has no effect [-Wunused-value]
  for (u+=MAX;u>0;u>>1)sum+=tree[u];
                  ~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...