Submission #650330

# Submission time Handle Problem Language Result Execution time Memory
650330 2022-10-13T13:40:27 Z 600Mihnea Fire (JOI20_ho_t5) C++17
0 / 100
1000 ms 15892 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct Op {
	int limit;
	int k;
	int id;
};

int main() {
#ifndef ONPC
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
	
	int n, q;
	cin >> n >> q;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	// l, r, t
	vector<ll> prn(2 * q, 0);
	vector<Op> ops;
	for (int i = 0; i < q; i++) {
		int l, r, t;
		cin >> t >> l >> r;
		l--, r--;
		ops.push_back({l - 1, t, i});
		ops.push_back({r, t, i + q});
	}
	
	for (auto &it : ops) {
		int limit = it.limit;
		if (limit < 0) {
			//cout << "skip\n";
			continue;
		}
		int k = it.k;
		int id = it.id;
		ll sol = 0;
		for (int i = 0; i <= limit; i++) {
			ll mx = a[i];
			for (int j = i; j >= i - k + 1 && j >= 0; j--) {
				mx = max(mx, a[j]);
			}
			sol += mx;
		}
		prn[id] = sol;
	}
	for (int i = 0; i < q; i++) {
		cout << prn[i + q] - prn[i] << "\n";
	}
	cout << "\n";

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 3 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 1074 ms 15892 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 1074 ms 15804 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 11068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 3 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -