Submission #156828

#TimeUsernameProblemLanguageResultExecution timeMemory
156828staniewzkiFoehn Phenomena (JOI17_foehn_phenomena)C++14
100 / 100
152 ms11732 KiB
#include<bits/stdc++.h>
using namespace std;

ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}
 
#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }

using LL = long long;
using PII = pair<int, int>;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	LL n, q, s, t;
	cin >> n >> q >> s >> t;
	vector<LL> delta(n);
	LL ans = 0, last, h;
	cin >> last;

	auto add_delta = [&](int i, int sign) {
		if(delta[i] < 0) ans -= delta[i] * t * sign;
		else ans -= delta[i] * s * sign;
	};

	REP(i, n) {
		cin >> h;
		delta[i] = h - last;
		last = h;
		add_delta(i, +1);
	}

	debug(delta, ans);

	REP(i, q) {
		LL l, r, x;
		cin >> l >> r >> x;

		for(int j : {l - 1, r}) {
			if(j == n) continue;
			add_delta(j, -1);
			delta[j] += x * (j == r ? -1 : +1);
			add_delta(j, +1);
		}

		debug(delta);
		cout << ans << "\n";
	}
}

Compilation message (stderr)

foehn_phenomena.cpp: In function 'int main()':
foehn_phenomena.cpp:64:19: warning: statement has no effect [-Wunused-value]
  debug(delta, ans);
                   ^
foehn_phenomena.cpp:77:15: warning: statement has no effect [-Wunused-value]
   debug(delta);
               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...