Submission #412445

#TimeUsernameProblemLanguageResultExecution timeMemory
412445OzyFoehn Phenomena (JOI17_foehn_phenomena)C++17
100 / 100
237 ms16792 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for (int i = (a); i <= (b); i++) #define repa(i,a,b) for (int i = (a); i >= (b); i--) #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define tam 200002 #define alt(x) (arr[x] + query(x)) lli BIT[tam],arr[tam],ST[(1<<19)+2]; lli n,q,s,t,a,b,l,r,c,offset,d; void agrega(lli pos, lli val) { while (pos < tam) { BIT[pos] += val; pos += pos&(-pos); } } lli query(lli pos) { lli res = 0; while (pos > 0) { res += BIT[pos]; pos -= pos&(-pos); } return res; } void actualiza(lli nodo, lli val) { lli mitad,a,b; ST[nodo] = val; nodo /= 2; while (nodo > 0) { ST[nodo] = ST[nodo*2] + ST[(nodo*2)+1]; nodo /= 2; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> q >> s >> t; rep(i,0,n) cin >> arr[i]; s *= -1; offset = 1; while (offset < n) offset<<=1; rep(i,0,n-1) { a = arr[i]; b = arr[i+1]; c = (a<b)? (b-a)*s : (a-b)*t; ST[offset+i] = c; } repa(i,offset-1,1) ST[i] = ST[i<<1] + ST[(i<<1)+1]; rep(i,1,q) { cin >> l >> r >> c; agrega(l,c); agrega(r+1,-c); a = alt(l-1); b = alt(l); c = (a<b)? (b-a)*s : (a-b)*t; actualiza(l+offset-1, c); if (r < n) { a = alt(r); b = alt(r+1); c = (a<b)? (b-a)*s : (a-b)*t; actualiza(r+offset, c); } cout << ST[1] << "\n"; } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'void actualiza(long long int, long long int)':
foehn_phenomena.cpp:33:9: warning: unused variable 'mitad' [-Wunused-variable]
   33 |     lli mitad,a,b;
      |         ^~~~~
foehn_phenomena.cpp:33:15: warning: unused variable 'a' [-Wunused-variable]
   33 |     lli mitad,a,b;
      |               ^
foehn_phenomena.cpp:33:17: warning: unused variable 'b' [-Wunused-variable]
   33 |     lli mitad,a,b;
      |                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...