Submission #153273

#TimeUsernameProblemLanguageResultExecution timeMemory
153273HideoFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
188 ms16464 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mk make_pair #define fr first #define sc second #define vi vector < int > #define pi pair < int, int > const int N = 1e6 + 7; const int INF = 1e9 + 7; vector < ll > vec; ll a[N], val[N], sum[N], ans; ll n, q, s, t; main(){ cin >> n >> q >> s >> t; for (int i = 0; i <= n; i++){ scanf("%lld", &a[i]); if (i) val[i] = a[i - 1] - a[i]; sum[i] = val[i]; if (sum[i] > 0) sum[i] *= t; else sum[i] *= s; ans += sum[i]; } while (q--){ ll l, r, x; scanf("%lld%lld%lld", &l, &r, &x); r++; val[l] -= x; if (r <= n) val[r] += x; ans -= (sum[l] + sum[r]); sum[l] = val[l]; sum[r] = val[r]; if (sum[l] > 0) sum[l] *= t; else sum[l] *= s; if (sum[r] > 0) sum[r] *= t; else sum[r] *= s; ans += (sum[l] + sum[r]); vec.pb(ans); } for (ll to : vec) printf("%lld\n", to); }

Compilation message (stderr)

foehn_phenomena.cpp:19:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &a[i]);
         ~~~~~^~~~~~~~~~~~~~~
foehn_phenomena.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         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...