Submission #751668

#TimeUsernameProblemLanguageResultExecution timeMemory
751668vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
1066 ms3660 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main () { int n,q,s,t; cin >> n >> q >> s >> t; int high[n]; int x = 0, y = 0; for (int i=0;i<=n;i++) { int temp; cin >> temp; high[i] = temp; if (i>0) { if (temp>high[i-1]) {x += temp - high[i-1];} if (temp<high[i-1]) {y += high[i-1] - temp;} } } int suhu = x*(-s) + y*t; for (int i=0;i<q;i++) { int l,r,j; cin >> l >> r >> j; int ltemp = high[l] + j; int rtemp = high[r] + j; int jtemp = j; if (j<0) j *= -1; if (high[l] < high[l-1]) { if (ltemp > high[l-1]) { x += ltemp - high[l-1]; y -= j - (ltemp - high[l-1]); } else if (ltemp < high[l-1]) { if (high[l-1]-high[l] > high[l-1]-ltemp) { y -= j; } else y += j; } else { y -= j; } } if (high[l] > high[l-1]) { if (ltemp < high[l-1]) { x -= j - (high[l-1] - ltemp); y += high[l-1] - ltemp; } else if (ltemp > high[l-1]) { if (high[l]-high[l-1] > ltemp-high[l-1]) { x -= j; } else x += j; } else { x -= j; } } if (r!=n) { if (high[r] < high[r+1]) { if (rtemp > high[r+1]) { x -= j - (rtemp - high[r+1]); y += rtemp - high[r+1]; } else if (rtemp < high[r+1]) { if (high[r+1]-high[r] > high[r+1]-rtemp) { x -= j; } else x += j; } else { x -= j; } } if (high[r] > high[r+1]) { if (rtemp < high[r+1]) { x += high[r+1] - rtemp; y -= j - (high[r+1] - rtemp); } else if (rtemp > high[r+1]){ if (high[r]-high[r+1] > rtemp-high[r+1]) { y -= j; } else y += j; } else { y -= j; } } } suhu = x*(-s) + y*t; cout << suhu << endl; for (int a=l;a<=r;a++) { high[a] += jtemp; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...