Submission #51444

#TimeUsernameProblemLanguageResultExecution timeMemory
51444DatcoollzFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
209 ms6056 KiB
#include <vector> #include <iostream> #include <stdio.h> using namespace std; typedef vector<long long> vi; long long n, q, s, t, temp = 0; vi a; void run(long long l, long long r, long long v) { long long ll = l - 1, rr = r; long long val=0; if(ll>=0){ val-=a[ll]*(a[ll]<0?s:t); a[ll]-=v; val+=a[ll]*(a[ll]<0?s:t); } if(rr<n){ val-=a[rr]*(a[rr]<0?s:t); a[rr]+=v; val+=a[rr]*(a[rr]<0?s:t); } temp+=val; printf("%lld\n",temp); return; } int main() { //freopen("inp.txt", "r", stdin); //freopen("out.txt", "w", stdout); scanf("%lld %lld %lld %lld", &n, &q, &s, &t); long long prev; scanf("%lld", &prev); for (int i = 1; i <= n; i++) { long long inp; scanf("%lld", &inp); long long num = prev - inp; a.push_back(num); temp += (num * (num < 0 ? s : t)); prev = inp; } for (int i = 0; i < q; i++) { long long l, r, v; scanf("%lld %lld %lld", &l, &r, &v); run(l, r, v); } }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld %lld %lld %lld", &n, &q, &s, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &prev);
     ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:41:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &inp);
         ~~~~~^~~~~~~~~~~~~~
foehn_phenomena.cpp:50:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld %lld", &l, &r, &v);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...