Submission #114262

#TimeUsernameProblemLanguageResultExecution timeMemory
114262kimjg1119Foehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
188 ms11484 KiB
#include <bits/stdc++.h> #define MAXN 200005 using namespace std; typedef long long ll; ll sig[MAXN]; ll n, q, s, t, temp = 0; ll pre(ll k) { if (k >= 0) return -s * k; else return -t * k; } ll func(ll pos, ll diff) { ll a = pre(sig[pos]), b = pre(sig[pos] + diff); return b - a; } int main() { scanf("%lld %lld %lld %lld", &n, &q, &s, &t); ll bf; scanf("%lld", &bf); for (int i = 1; i <= n; i++) { ll tz; scanf("%lld", &tz); sig[i] = tz - bf; bf = tz; if (sig[i] >= 0) temp -= sig[i] * s; else temp -= sig[i] * t; } while (q--) { ll x, y, diff, ord; scanf("%lld %lld %lld", &x, &y, &diff); temp += func(x, diff); sig[x] += diff; if (y == n) diff = 0; temp += func(y + 1, -diff); sig[y + 1] -= diff; printf("%lld\n", temp); } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:32:18: warning: unused variable 'ord' [-Wunused-variable]
   ll x, y, diff, ord;
                  ^~~
foehn_phenomena.cpp:21: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:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  ll bf; scanf("%lld", &bf);
         ~~~~~^~~~~~~~~~~~~
foehn_phenomena.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", &tz);
   ~~~~~^~~~~~~~~~~~~
foehn_phenomena.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld %lld", &x, &y, &diff);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...