Submission #364992

#TimeUsernameProblemLanguageResultExecution timeMemory
364992Mamnoon_SiamFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
154 ms13164 KiB
#include <bits/stdc++.h> using namespace std; /* sorry, this is the bare minimum :'( */ using ll = long long; using ii = pair<int, int>; using vi = vector<int>; #define all(v) begin(v), end(v) #define sz(v) (int)(v).size() #define fi first #define se second const int N = 2e5 + 5; int n, q; ll S, T; ll a[N], d[N]; int main(int argc, char const *argv[]) { #ifdef LOCAL freopen("in", "r", stdin); #endif scanf("%d %d %lld %lld", &n, &q, &S, &T); ll ans = 0; function<void(int,int)> work = [&ans](int i, int x) { if(d[i] >= 0) ans -= S * d[i]; else ans -= T * d[i]; d[i] += x; if(d[i] >= 0) ans += S * d[i]; else ans += T * d[i]; }; for(int i = 0; i <= n; ++i) { scanf("%lld", &a[i]); if(i) { d[i] = a[i] - a[i-1]; if(d[i] >= 0) { ans += S * d[i]; } else { ans += T * d[i]; } } } while(q--) { int l, r, x; scanf("%d %d %d", &l, &r, &x); // debug(l, r, x); work(l, x); if(r < n) work(r+1, -x); printf("%lld\n", -ans); } return 0; }

Compilation message (stderr)

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