Submission #535788

#TimeUsernameProblemLanguageResultExecution timeMemory
535788abc864197532Fire (JOI20_ho_t5)C++17
1 / 100
146 ms262144 KiB
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define pii pair<int,int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
void abc() {cout << endl;}
template <typename T, typename ...U> void abc(T i, U ...j) {
	cout << i << ' ', abc(j...);
}
template <typename T> void printv(T l, T r) {
	for (; l != r; ++l)
		cout << *l << " \n"[l + 1 == r];
}
#ifdef Doludu
#define test(x...) abc("[" + string(#x) + "]", x)
#define owo freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#else
#define test(x...) void(0)
#define owo ios::sync_with_stdio(false), cin.tie(0)
#endif

int main () {
	owo;
	int n, q;
	cin >> n >> q;
	vector <vector <int>> now(n + 1, vector <int> (n, 0));
	for (int i = 0; i < n; ++i)
		cin >> now[0][i];
	for (int i = 1; i <= n; ++i) for (int j = 0; j < n; ++j) {
		now[i][j] = max(j ? now[i - 1][j - 1] : 0, now[i - 1][j]);
	}
	while (q--) {
		int t, l, r;
		cin >> t >> l >> r, --l;
		lli ans = 0;
		for (int i = l; i < r; ++i)
			ans += now[t][i];
		cout << ans << '\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...