Submission #1116351

#TimeUsernameProblemLanguageResultExecution timeMemory
1116351staszic_ojuzFoehn Phenomena (JOI17_foehn_phenomena)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); ios_base::sync_with_stdio(0); int n, q, s, t; cin >> n >> q >> s >> t; int pop, ter; cin >> pop; vector<int> roz; for(int i = 0; i < n; ++i) { cin >> ter; roz.push_back(ter - pop); pop = ter; } roz.push_back(0); ll odp = 0; for(int i = 0; i < n; ++i) { if(roz[i] > 0) odp -= s*roz[i]; else odp -= t*roz[i]; } for(int i = 0; i < q; ++i) { int l, r, x; cin >> l >> r >> x; int a = roz[l-1]; if(r < n) int b = roz[r]; roz[l-1] += x; if(r < n) roz[r] -= x; if(a > 0 && roz[l-1] <= 0) odp += s*a - t*roz[l-1]; if(a <= 0 && roz[l-1] > 0) odp -= s*roz[l-1] - t*a; if(a > 0 && roz[l-1] > 0) odp += s*a - s*roz[l-1]; if(a <= 0 && roz[l-1] <= 0) odp += t*a - t*roz[l-1]; if(r >= n) { cout << odp << "\n"; continue; } if(b > 0 && roz[r] <= 0) odp += s*b - t*roz[r]; if(b <= 0 && roz[r] > 0) odp -= s*roz[r] - t*b; if(b > 0 && roz[r] > 0) odp += s*b - s*roz[r]; if(b <= 0 && roz[r] <= 0) odp += t*b - t*roz[r]; cout << odp << "\n"; } }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:35:17: warning: unused variable 'b' [-Wunused-variable]
   35 |             int b = roz[r];
      |                 ^
foehn_phenomena.cpp:52:12: error: 'b' was not declared in this scope
   52 |         if(b > 0 && roz[r] <= 0)
      |            ^
foehn_phenomena.cpp:54:12: error: 'b' was not declared in this scope
   54 |         if(b <= 0 && roz[r] > 0)
      |            ^
foehn_phenomena.cpp:56:12: error: 'b' was not declared in this scope
   56 |         if(b > 0 && roz[r] > 0)
      |            ^
foehn_phenomena.cpp:58:12: error: 'b' was not declared in this scope
   58 |         if(b <= 0 && roz[r] <= 0)
      |            ^