QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#49768 | #2283. Decelerating Jump | asdasdasfasdfasdfsdaf | TL | 0ms | 0kb | C++11 | 1.8kb | 2022-09-22 23:21:01 | 2022-09-22 23:21:02 |
Judging History
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;
}
详细
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...