QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#49768#2283. Decelerating JumpasdasdasfasdfasdfsdafTL 0ms0kbC++111.8kb2022-09-22 23:21:012022-09-22 23:21:02

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-22 23:21:02]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2022-09-22 23:21:01]
  • 提交

answer

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cstring>
#include <functional>
#include <algorithm>
#include <bitset>
#include <numeric>

#define sk(i, x) for(uint64_t i = 0; i < x; i++) 
#define skc(i, start, x) for(uint64_t i = start; i < x; i++) 
#define skci(i, start, increment, x) for(uint64_t i = start; i < x; i+=increment) 


#define chin(x) char x; std::cin >> x;
#define slin(x) int64_t x; std::cin >> x
#define lin(x) uint64_t x; std::cin >> x
#define qsort(x) std::sort(x.begin(), x.end())
#define qmaxv(x) *std::max_element(x.begin(), x.end());
#define vsum(x) std::accumulate( x.begin(), x.end(), 0 )

typedef std::vector<int64_t> slv;
typedef std::vector<uint64_t> uslv;
typedef std::vector<int32_t> siv;
typedef std::vector<uint32_t> uiv;
typedef std::vector<bool> bv;



slv squares;

int get_max_score( int index, int jump_length, int score )
{
	if( index == squares.size() - 2 ) {
		return score;
	}
	int best_score = -999999999;
	for( jump_length; jump_length > 0; jump_length-- ) {
		int lookup_index = index + jump_length;
		if( lookup_index > squares.size() - 2 ) {
			continue;
		}
		int add_to_score = squares[lookup_index];
		int next_score = get_max_score( index + jump_length, jump_length, score + add_to_score );
		if( next_score > best_score ) {
			best_score = next_score;
		}
	}
	return best_score;
}

int main()
{
	lin( n );
	squares.resize( n );
	sk( i, n )
	{
		slin( a );
		squares[i] = a;
	}
	int64_t highest_score = -999999;
	skc( start_pos, 1, n )
	{
		int64_t score = squares[0] + squares[n - 1];

		score += get_max_score( start_pos, start_pos, 0 );
		if( score > highest_score ) {
			highest_score = score;
		}
	}
	std::cout << highest_score << "\n";
	return 0;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:


result: