Submission #531121

#TimeUsernameProblemLanguageResultExecution timeMemory
531121ioiFoehn Phenomena (JOI17_foehn_phenomena)C++14
30 / 100
1071 ms2044 KiB
#include<bits/stdc++.h> using namespace std; #define debug(x) cout << '[' << #x << " is: " << x << "] " << endl; #define inF freopen("6in.txt" , "r" , stdin); #define outF freopen("6.txt" , "w" , stdout); #define imod(a , n) (a % n + n ) % n #define sor(v) sort(v.begin() , v.end()); #define print(v) for(auto f : v ) cout << f << " " ; #define rsor(v) sort(v.rbegin() , v.rend()); #define rev(v) reverse(v.begin() , v.end()); #define scan(v)for(auto &it : v)cin >> it ; #define ll long long //#define int ll #define logar(x , y) log(x) / log(y) #define __sum(n) n * (n + 1) / 2 #define __lcm(a , b) a / __gcd(a , b) * b #define pii pair<int , int > #define fastio ios_base::sync_with_stdio(false);cin.tie(0); const int N = 1e3 + 5 , M = N * 64 , MX = 2e4 + 40; const ll MOD = 1e9 + 7 , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ; const double pi = acos(-1) , eps = 1e-17 ; int di[] = {1 , -1 , 0 , 0}; int dj[] = {0 , 0 , -1 , 1}; int32_t main() { //inF; //inF;outF; fastio; int n , q , s , t ; cin >> n>> q >> s >> t ; long long arr[n + 1]; for(int i = 0 ; i < n + 1; i ++)cin >> arr[i]; while(q--){ int l , r , x ; cin >> l >> r >> x ; while(l <= r)arr[l++] += x ; long long ans = 0 ; for(int i = 1 ; i < n + 1 ; i ++){ //debug(arr[i])// cout << arr[i] << " "; long long d = abs(arr[i] - arr[i - 1]); if(arr[i - 1] < arr[i])ans -= s * d ; else ans += t * d ; } cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...