Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
98063 ZZQ 早凉的函数2 C++ 运行超时 0 1000 MS 1016 KB 922 2023-08-14 11:57:36

Tests(0/5):


//20pts #include <bits/stdc++.h> using namespace std; inline int Read() { int x = 0 , f = 1; char c = getchar(); for( ; c < '0' || c > '9' ; c = getchar() ) f ^= ( c == '-' ); for( ; c >= '0' && c <= '9' ; c = getchar() ) x = ( x << 3 ) + ( x << 1 ) + ( c ^ 48 ); return f ? x : -x; } const int _ = 2e5 + 5; int n , k , v , ans; int a[_]; void DFS( int x , int num ) { if( num == k ) { int sum = 0; for( int i = 1 ; i <= n ; i++ ) { sum += a[ i ] - v; if( sum < 0 ) sum = 0; ans = max( ans , sum ); } return; } if( x > n ) return; DFS( x + 1 , num ); a[ x ] += 2 * v; DFS( x + 1 , num + 1 ); a[ x ] -= 2 * v; } void Subtask1() { DFS( 1 , 0 ); cout << ans << '\n'; } int main() { n = Read() , k = Read() , v = Read(); for( int i = 1 ; i <= n ; i++ ) { a[ i ] = Read(); } if( n <= 8 ) Subtask1(); return 0; }


测评信息: