Submission #50253

#TimeUsernameProblemLanguageResultExecution timeMemory
50253gs13105Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
238 ms167876 KiB
#include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <iterator> using namespace std; const int MAXN = 200000; long long arr[MAXN + 10]; int main() { //freopen("in", "r", stdin); //freopen("out", "w", stdout); int n, q, s, t, i; scanf("%d%d%d%d", &n, &q, &s, &t); int a, p; for(i = 0; i < n + 1; i++) { scanf("%d", &a); if(i != 0) arr[i] = a - p; p = a; } long long c = 0; for(i = 1; i <= n; i++) c -= 1LL * (arr[i] > 0 ? s : t) * arr[i]; for(i = 0; i < q; i++) { int l, r, x; scanf("%d%d%d", &l, &r, &x); c += 1LL * (arr[l] > 0 ? s : t) * arr[l]; arr[l] += x; c -= 1LL * (arr[l] > 0 ? s : t) * arr[l]; r++; if(r != n + 1) { c += 1LL * (arr[r] > 0 ? s : t) * arr[r]; arr[r] -= x; c -= 1LL * (arr[r] > 0 ? s : t) * arr[r]; } printf("%lld\n", c); } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d%d", &n, &q, &s, &t);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
foehn_phenomena.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a);
         ~~~~~^~~~~~~~~~
foehn_phenomena.cpp:49:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         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...