Submission #129323

#TimeUsernameProblemLanguageResultExecution timeMemory
129323trinhhungFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1038 ms4968 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 5; int n, s, t, q, ans = 0; int a[N], f[N]; main(){ //ios_base::sync_with_stdio(false); //cin.tie(nullptr); cin >> n >> q >> s >> t; for(int i = 0; i <= n; ++ i) cin >> a[i]; for(int i = 1; i <= n; ++ i){ f[i] = a[i] - a[i-1]; if(f[i] > 0) ans = ans - f[i] * s; else ans = ans - f[i] * t; } while(q --){ int l, r, x; cin >> l >> r >> x; if(f[l] > 0) ans += f[l] * s; else ans += f[l] * t; f[l] += x; if(f[l] > 0) ans -= f[l] * s; else ans -= f[l] * t; if(r >= n){ cout << ans << '\n'; continue; } if(f[r + 1] > 0) ans += f[r + 1] * s; else ans += f[r + 1] * t; f[r + 1] -= x; if(f[r + 1] > 0) ans -= f[r + 1] * s; else ans -= f[r + 1] * t; cout << ans << '\n'; } }

Compilation message (stderr)

foehn_phenomena.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...