Submission #842656

#TimeUsernameProblemLanguageResultExecution timeMemory
842656EntityPlanttFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
95 ms11576 KiB
#include <cstdio> #define int long long const int mxn = 200005; int n, q, s, t, h1, h2, delta[mxn], i, res, l, r, x; signed main() { scanf("%lld%lld%lld%lld%lld", &n, &q, &s, &t, &h1); for (i = 0; i < n; i++) { scanf("%lld", &h2); delta[i] = h2 - h1; if (delta[i] > 0) res -= s * delta[i]; else res -= t * delta[i]; h1 = h2; } while (q--) { scanf("%lld%lld%lld", &l, &r, &x); l--; if (l >= 0) { if (delta[l] > 0) res += s * delta[l]; else res += t * delta[l]; delta[l] += x; if (delta[l] > 0) res -= s * delta[l]; else res -= t * delta[l]; } if (r < n) { if (delta[r] > 0) res += s * delta[r]; else res += t * delta[r]; delta[r] -= x; if (delta[r] > 0) res -= s * delta[r]; else res -= t * delta[r]; } printf("%lld\n", res); } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:6:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |     scanf("%lld%lld%lld%lld%lld", &n, &q, &s, &t, &h1);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         scanf("%lld", &h2);
      |         ~~~~~^~~~~~~~~~~~~
foehn_phenomena.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld%lld%lld", &l, &r, &x);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...