Submission #287582

#TimeUsernameProblemLanguageResultExecution timeMemory
287582fgojkoFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
553 ms11896 KiB
#include <iostream> #include <vector> //#define FEEDBACK using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); int n, q; ll s, t; cin >> n >> q >> s >> t; s *= -1; vector<ll> vec(n); ll l1, l2; cin >> l1; ll temp = 0; for(int i = 0; i < n; ++i){ cin >> l2; vec[i] = l1-l2; if(vec[i] < 0){ temp -= vec[i]*s; } else{ temp += vec[i]*t; } l1 = l2; } int l, k; ll x, y; vector<ll> res(q); bool b1, b2; for(int i = 0; i < q; ++i){ cin >> l >> k >> x; --l; y = vec[l]; vec[l] -= x; if(y < 0){ temp += y*s; } else{ temp -= y*t; } if(vec[l] < 0){ temp -= vec[l]*s; } else{ temp += vec[l]*t; } if(k < n){ y = vec[k]; vec[k] += x; if(y < 0){ temp += y*s; } else{ temp -= y*t; } if(vec[k] < 0){ temp -= vec[k]*s; } else{ temp += vec[k]*t; } } res[i] = temp; } for(int i = 0; i < q; ++i){ cout << res[i] << endl; } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:35:10: warning: unused variable 'b1' [-Wunused-variable]
   35 |     bool b1, b2;
      |          ^~
foehn_phenomena.cpp:35:14: warning: unused variable 'b2' [-Wunused-variable]
   35 |     bool b1, b2;
      |              ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...