Submission #489483

# Submission time Handle Problem Language Result Execution time Memory
489483 2021-11-23T03:37:33 Z fhvirus Triple Jump (JOI19_jumps) C++17
19 / 100
372 ms 144668 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef pair<int, int> pii;
#define ff first
#define ss second
#define pb emplace_back
#define AI(x) begin(x),end(x)
template<class I> bool chmin(I&a, I b){ return a > b ? (a=b, true) : false; }
template<class I> bool chmax(I&a, I b){ return a < b ? (a=b, true) : false; }
#ifdef OWO
#define debug(args...) LKJ("\033[1;32m[ " + string(#args) + " ]\033[0m", args)
template<class I> void LKJ(I&&x){ cerr << x << endl; }
template<class I, class...T> void LKJ(I&&x, T&&...t){ cerr << x << ", "; LKJ(t...); }
template<class I> void OI(I a, I b){ while(a < b) cerr << *a << " \n"[next(a) == b], ++a; }
#else
#define debug(...) 0
#define OI(...) 0
#endif

// const int kN = 500005;
const int kN = 5005;
const int kQ = 500005;
int N, Q, A[kN];
int L[kQ], R[kQ];

void input(){
	cin >> N;
	for(int i = 1; i <= N; ++i)
		cin >> A[i];
	cin >> Q;
	for(int i = 0; i < Q; ++i)
		cin >> L[i] >> R[i];
}

int rm[kN][kN];
int ans[kN][kN];
void solve(){
	for(int i = 1; i <= N; ++i){
		for(int j = i; j <= N; ++j)
			rm[i][j] = max(rm[i][j-1], A[j]);
	}
	for(int i = 1; i <= N; ++i){
		for(int j = i+2; j <= N; ++j){
			ans[i][j] = A[i] + A[j] + rm[i+1][i+(j-i)/2];
		}
	}
	for(int i = 1; i <= N; ++i)
		for(int j = i+2; j <= N; ++j)
			ans[i][j] = max(ans[i][j], ans[i][j-1]);

	for(int i = N-1; i >= 1; --i)
		for(int j = i+2; j <= N; ++j)
			ans[i][j] = max(ans[i][j], ans[i+1][j]);

	for(int i = 0; i < Q; ++i)
		cout << ans[L[i]][R[i]] << '\n';
}

signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	input();
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1100 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1092 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 1 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1100 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1092 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 1 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
11 Correct 348 ms 144668 KB Output is correct
12 Correct 331 ms 144452 KB Output is correct
13 Correct 332 ms 144436 KB Output is correct
14 Correct 326 ms 144504 KB Output is correct
15 Correct 329 ms 144448 KB Output is correct
16 Correct 347 ms 143832 KB Output is correct
17 Correct 372 ms 143784 KB Output is correct
18 Correct 318 ms 143760 KB Output is correct
19 Correct 342 ms 144448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 216 ms 584 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 1 ms 1100 KB Output is correct
4 Correct 1 ms 1100 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 1092 KB Output is correct
7 Correct 1 ms 1100 KB Output is correct
8 Correct 1 ms 1100 KB Output is correct
9 Correct 1 ms 1100 KB Output is correct
10 Correct 1 ms 1100 KB Output is correct
11 Correct 348 ms 144668 KB Output is correct
12 Correct 331 ms 144452 KB Output is correct
13 Correct 332 ms 144436 KB Output is correct
14 Correct 326 ms 144504 KB Output is correct
15 Correct 329 ms 144448 KB Output is correct
16 Correct 347 ms 143832 KB Output is correct
17 Correct 372 ms 143784 KB Output is correct
18 Correct 318 ms 143760 KB Output is correct
19 Correct 342 ms 144448 KB Output is correct
20 Runtime error 216 ms 584 KB Execution killed with signal 11
21 Halted 0 ms 0 KB -