Submission #129297

#TimeUsernameProblemLanguageResultExecution timeMemory
129297MrUnknownFoehn Phenomena (JOI17_foehn_phenomena)C++11
100 / 100
181 ms7292 KiB
/*** * __ __ _ _ _ * | \/ | | | | | | | * | \ / |_ __ | | | |_ __ | | ___ __ _____ ___ __ * | |\/| | '__| | | | | '_ \| |/ / '_ \ / _ \ \ /\ / / '_ \ * | | | | | _ | |__| | | | | <| | | | (_) \ V V /| | | | * |_| |_|_| (_) \____/|_| |_|_|\_\_| |_|\___/ \_/\_/ |_| |_| * * ***/ #include<stdio.h> #include<bits/stdc++.h> using namespace std; #define ll long long #define f(i,a,b) for (int i=a;i<=b;i++) #define f_(i,a,b) for (int i=a;i>=b;i--) #define MP make_pair #define ii pair<int,int> #define iii pair<int,ii> const ll mod=1000000007; int n,q; ll s,t,a[200005],hieu[200005],tong=0; int main() { // freopen("","r",stdin); // freopen("","w",stdout); scanf("%d %d %lld %lld", &n, &q, &s, &t); f(i,0,n) { scanf("%lld", &a[i]); if (i>0) hieu[i]=a[i]-a[i-1]; if (hieu[i]>=0) tong-=s*hieu[i]; else tong-=t*hieu[i]; } // f(i,0,n) cout<<a[i]<<" "; // cout<<"\n"; // cout<<"!"<<tong<<"\n"; // cout<<"check: "; // f(i,1,n) cout<<hieu[i]<<" "; // cout<<"\n"; while (q--) { int l,r; ll x; scanf("%d %d %lld", &l, &r, &x); if (l!=0) { if (hieu[l]>=0) tong+=s*hieu[l]; else tong+=t*hieu[l]; } if (r!=n) { if (hieu[r+1]>=0) tong+=s*hieu[r+1]; else tong+=t*hieu[r+1]; } // cout<<" "<<tong<<" "<<hieu[l]<<" "<<hieu[r+1]<<"\n"; if (l!=0) hieu[l]+=x; if (r!=n) hieu[r+1]-=x; // cout<<"check: "; // f(i,1,n) cout<<hieu[i]<<" "; // cout<<"\n"; // cout<<" "<<tong<<" "<<hieu[l]<<" "<<hieu[r+1]<<" "; if (l!=0) { if (hieu[l]>=0) tong-=s*hieu[l]; else tong-=t*hieu[l]; } if (r!=n) { if (hieu[r+1]>=0) tong-=s*hieu[r+1]; else tong-=t*hieu[r+1]; } printf("%lld\n", tong); } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %lld %lld", &n, &q, &s, &t);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &a[i]);
   ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:43:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %lld", &l, &r, &x);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...