Submission #26930

#TimeUsernameProblemLanguageResultExecution timeMemory
26930kajebiiiFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
226 ms5144 KiB
#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)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:28:47: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<=N; i++) scanf("%lld", &Nr[i]);
                                               ^
foehn_phenomena.cpp:35:43: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x, y, t; scanf("%d%d%d", &x, &y, &t);
                                           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...