# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
26930 | kajebiii | Foehn Phenomena (JOI17_foehn_phenomena) | C++14 | 226 ms | 5144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef tuple<int, int, int> ti;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF;
const int MAX_N = 2e5 + 100;
int N, S, T, Q;
ll Nr[MAX_N], Diff[MAX_N];
ll getV(ll d) {
if(d > 0) return -S * d;
return T * -d;
}
int main() {
cin >> N >> Q >> S >> T;
for(int i=0; i<=N; i++) scanf("%lld", &Nr[i]);
for(int i=0; i<N; i++) Diff[i] = Nr[i+1] - Nr[i];
ll ans = 0;
for(int i=0; i<N; i++) ans += getV(Diff[i]);
while(Q--) {
int x, y, t; scanf("%d%d%d", &x, &y, &t);
ans -= getV(Diff[x-1]); ans += getV(Diff[x-1] += t);
if(y == N) {printf("%lld\n", ans); continue;}
ans -= getV(Diff[y]); ans += getV(Diff[y] -= t);
printf("%lld\n", ans);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |