Submission #58785

#TimeUsernameProblemLanguageResultExecution timeMemory
58785leejseoFoehn Phenomena (JOI17_foehn_phenomena)C++98
100 / 100
277 ms144660 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lld; const int MAXN = 200001; lld A[MAXN+2], S, T, ans; int N, Q, L[MAXN+1]; inline lld sum_val(lld x) {return x > 0 ? -S*x : -T*x;} void input(){ scanf("%d%d%lld%lld", &N, &Q, &S, &T); for (int i=0; i<=N; i++) scanf("%d", &L[i]); for (int i=1; i<=N; i++){ A[i] = L[i] - L[i-1]; ans += sum_val(A[i]); } } int main(){ input(); int u, v; lld w; while (Q--){ scanf("%d%d%lld", &u, &v, &w); ans -= sum_val(A[u]); A[u] += w; ans += sum_val(A[u]); if (v != N){ ans -= sum_val(A[v+1]); A[v+1] -= w; ans += sum_val(A[v+1]); } printf("%lld\n", ans); } }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'void input()':
foehn_phenomena.cpp:13: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:14:32: 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("%d", &L[i]);
                           ~~~~~^~~~~~~~~~~~~
foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%lld", &u, &v, &w);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...