ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#208258 | #3774. Circular Platform Clutter | _Alexande_ | 100 | 1014ms | 180948kb | C++11 | 1.7kb | 2024-08-02 09:13:50 | 2024-08-02 12:43:12 |
answer
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd ( time ( 0 ) );
#define int long long
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define lep( i, l, r ) for ( int i = ( l ); i <= ( r ); ++ i )
#define rep( i, r, l ) for ( int i = ( r ); i >= ( l ); -- i )
typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
char _c; bool _f; template < class type > inline void read ( type &x ) {
_f = 0, x = 0;
while ( _c = getchar (), !isdigit ( _c ) ) if ( _c == '-' ) _f = 1;
while ( isdigit ( _c ) ) x = x * 10 + _c - '0', _c = getchar (); if ( _f ) { x = -x; }
}
template < class type > inline void chkmin ( type &x, type y ) { x = ( x <= y ? x : y ); }
template < class type > inline void chkmax ( type &x, type y ) { x = ( x >= y ? x : y ); }
const int N = 1e6 + 5;
int n, m, p, ans;
int a[N], f[11][N], suf[11][N], pre[N];
void Solve () {
ios :: sync_with_stdio ( false );
cin.tie ( 0 ), cout.tie ( 0 );
cin >> n >> m >> p;
for ( int i = 1; i <= n; i ++ ) {
cin >> a[i];
pre[i] = pre[i - 1] + a[i];
}
memset ( suf, 0xcf, sizeof ( suf ) );
for ( int i = 1; i <= m; i ++ ) {
for ( int j = i; j <= n; j ++ ) {
f[i][j] = p * ceil ( ( j - i + 1 ) * 1.0 / m );
}
for ( int j = n; j >= i; j -- ) {
suf[i][j] = max ( suf[i][j + 1], pre[j] - f[i][j] );
}
}
for ( int k = 1; k <= m; k ++ ) {
for ( int i = k, j = 0; i <= n; i += m, j ++ ) {
ans = max ( ans, j * p + suf[k][i] - pre[i - 1] );
}
}
cout << ans;
}
signed main () {
#ifdef judge
freopen ( "Code.in", "r", stdin );
freopen ( "Code.out", "w", stdout );
freopen ( "Code.err", "w", stderr );
#endif
Solve ();
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 4ms
memory: 87284kb
input:
2000 3 16685558 -289282588 -61747468 -657707881 -34145392 -537924930 -406398379 -542751658 -75231580...
output:
0
result:
ok 1 number(s): "0"
Test #2:
score: 10
Accepted
time: 3ms
memory: 87408kb
input:
2000 9 54576364 255242838 -740596945 -246472080 950729683 -533760302 935128112 511618036 -775471790 ...
output:
329933931328
result:
ok 1 number(s): "329933931328"
Test #3:
score: 10
Accepted
time: 4ms
memory: 87404kb
input:
2000 9 73094302 512084424 67433847 974023247 550398283 943786443 -472874397 138837755 -744203670 539...
output:
332791924952
result:
ok 1 number(s): "332791924952"
Test #4:
score: 10
Accepted
time: 139ms
memory: 126264kb
input:
1000000 3 0 133466399 -867775767 963834867 775948067 -832740810 -713930238 -308186786 556371611 2949...
output:
647512117689
result:
ok 1 number(s): "647512117689"
Test #5:
score: 10
Accepted
time: 260ms
memory: 180948kb
input:
1000000 10 0 664925048 -566073238 877788649 -841053552 -308215965 -412748922 -840978942 -932597488 -...
output:
946593412159
result:
ok 1 number(s): "946593412159"
Test #6:
score: 10
Accepted
time: 116ms
memory: 110640kb
input:
1000000 1 383781667 797002344 -71828458 -547854034 543934687 917387704 832016545 -978766494 78233955...
output:
11338880406
result:
ok 1 number(s): "11338880406"
Test #7:
score: 10
Accepted
time: 24ms
memory: 93472kb
input:
100000 6 986672506 539233196 995762687 47061599 -854879180 810700777 -663371439 989492494 986856326 ...
output:
13786459060670
result:
ok 1 number(s): "13786459060670"
Test #8:
score: 10
Accepted
time: 22ms
memory: 95832kb
input:
100000 9 964197836 970180324 -694572429 985191372 -727965595 526258804 -617811687 -612003824 5067943...
output:
18656797316158
result:
ok 1 number(s): "18656797316158"
Test #9:
score: 10
Accepted
time: 240ms
memory: 180944kb
input:
1000000 10 944196936 -998994854 973754696 975675616 992984745 116889413 -987876256 917812370 -892363...
output:
196532701874927
result:
ok 1 number(s): "196532701874927"
Test #10:
score: 10
Accepted
time: 202ms
memory: 173136kb
input:
1000000 9 813298367 888006085 185751739 -970868688 -793265934 606885815 970133239 888746315 29012399...
output:
181821174468687
result:
ok 1 number(s): "181821174468687"