제출 #954129

#제출 시각아이디문제언어결과실행 시간메모리
954129StefanSebezFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
129 ms13340 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N=2*1e5+50; ll p[N];int n; void Update(int qind,ll qval){ for(int i=qind;i<=n;i+=i&(-i)) p[i]+=qval; } int Get(int qind){ if(qind==0) return 0; ll sum=0; for(int i=qind;i>=1;i-=i&(-i)) sum+=p[i]; return sum; } //int Sum(int l,int r){return Get(r)-Get(l-1);} int main() { int q;ll S,T;scanf("%i%i%lld%lld",&n,&q,&S,&T); ll a[n+10];for(int i=0;i<=n;i++) scanf("%lld",&a[i]); ll b[n+10],res=0; for(int i=1;i<=n;i++){ if(a[i-1]<a[i]) b[i]=(a[i-1]-a[i])*S; else b[i]=(a[i-1]-a[i])*T; res+=b[i]; } //printf("%i\n",res); while(q--){ int l,r;ll x;scanf("%i%i%lld",&l,&r,&x); Update(l,x);Update(r+1,-x); ll temp=b[l],u=Get(l-1)+a[l-1],v=Get(l)+a[l]; if(u<v) b[l]=(u-v)*S; else b[l]=(u-v)*T; res+=b[l]-temp; //printf("%i %i %i %i\n",u,v,temp,b[l]); if(r+1<=n){ temp=b[r+1],u=Get(r)+a[r],v=Get(r+1)+a[r+1]; if(u<v) b[r+1]=(u-v)*S; else b[r+1]=(u-v)*T; res+=b[r+1]-temp; } printf("%lld\n",res); } return 0; }

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

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:18:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     int q;ll S,T;scanf("%i%i%lld%lld",&n,&q,&S,&T);
      |                  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:19:43: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     ll a[n+10];for(int i=0;i<=n;i++) scanf("%lld",&a[i]);
      |                                      ~~~~~^~~~~~~~~~~~~~
foehn_phenomena.cpp:28:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |   int l,r;ll x;scanf("%i%i%lld",&l,&r,&x);
      |                ~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...