답안 #242319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
242319 2020-06-27T08:47:50 Z shenxy 3단 점프 (JOI19_jumps) C++11
5 / 100
4000 ms 6888 KB
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> ii;
int main() {
	int N, Q, L, R;
	scanf("%d", &N);
	int A[N];
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	scanf("%d", &Q);
	if (Q == 1) {
		scanf("%d %d", &L, &R);
		--L, --R;
		vector<int> st;
		vector<ii> gps;
		for (int i = L; i <= R; ++i) {
			while (!st.empty() && A[st.back()] <= A[i]) gps.push_back(ii(st.back(), i)), st.pop_back();
			if (!st.empty()) gps.push_back(ii(st.back(), i));
			st.push_back(i);
		}
		int ans = 0;
		int SA[R - L + 1];
		SA[R - L] = A[R];
		for (int i = R - 1; i >= L; --i) SA[i - L] = max(SA[i - L + 1], A[i]);
		for (ii i: gps) ans = max(ans, A[i.first] + A[i.second] + SA[2 * i.second - i.first - L]);
		printf("%d", ans);
		return 0;
	}
	for (int i = 0; i < Q; ++i) {
		scanf("%d %d", &L, &R);
		--L, --R;
		int ans = 0;
		for (int i = L; i <= R; ++i) {
			for (int j = i + 1; j <= R; ++j) {
				for (int k = j + j - i; k <= R; ++k) ans = max(ans, A[i] + A[j] + A[k]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Compilation message

jumps.cpp: In function 'int main()':
jumps.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
jumps.cpp:10:35: 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("%d", &A[i]);
                              ~~~~~^~~~~~~~~~~~~
jumps.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &Q);
  ~~~~~^~~~~~~~~~
jumps.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &L, &R);
   ~~~~~^~~~~~~~~~~~~~~~~
jumps.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &L, &R);
   ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 360 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 360 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
11 Execution timed out 4067 ms 256 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 5356 KB Output is correct
2 Correct 43 ms 5352 KB Output is correct
3 Incorrect 43 ms 6888 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 360 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 256 KB Output is correct
6 Correct 6 ms 256 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 256 KB Output is correct
9 Correct 6 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
11 Execution timed out 4067 ms 256 KB Time limit exceeded
12 Halted 0 ms 0 KB -