Submission #51454

#TimeUsernameProblemLanguageResultExecution timeMemory
51454FutymyCloneFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
191 ms7508 KiB
#include <bits/stdc++.h> using namespace std; long long n, q, s, t, d[200010], a[200010], del, l, r, T0 = 0; int main() { scanf("%lld%lld%lld%lld", &n, &q, &s, &t); for(int i = 0; i <= n; i++) scanf("%lld", &a[i]); for(int i = 1; i <= n; i++) { d[i] = a[i] - a[i-1]; T0 += (d[i] >= 0 ? -d[i] * s : -d[i] * t); } while(q--) { scanf("%lld%lld%lld", &l, &r, &del); long long T = 0; T0 -= (d[l] >= 0 ? -d[l] * s : -d[l] * t); d[l] += del; T0 += (d[l] >= 0 ? -d[l] * s : -d[l] * t); if(r < n) { T0 -= (d[r+1] >= 0 ? -d[r+1] * s : -d[r+1] * t); d[r+1] -= del; T0 += (d[r+1] >= 0 ? -d[r+1] * s : -d[r+1] * t); } printf("%lld\n", T0); } }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:14:13: warning: unused variable 'T' [-Wunused-variable]
   long long T = 0; T0 -= (d[l] >= 0 ? -d[l] * s : -d[l] * t);
             ^
foehn_phenomena.cpp:6:7: 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:7:35: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i = 0; i <= n; i++) scanf("%lld", &a[i]);
                              ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld%lld", &l, &r, &del);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...