QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#336192 | #8281. Pangu and Stones | ucup-team052# | WA | 4ms | 8484kb | C++23 | 925b | 2024-02-24 13:52:05 | 2024-02-24 13:52:06 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, b, a) for (int i = b; i >= a; i--)
using namespace std;
const int P=998244353;
const int N=105,M=300005;
int n,L,R,a[N],sum[N];
int dp[N][N],f[N][N][N];
void umin(int &x,int y){if(y<x)x=y;}
int main() {
#ifdef xay5421
freopen("a.in","r",stdin);
#endif
cin>>n>>L>>R;
rep(i,1,n)cin>>a[i],sum[i]=sum[i-1]+a[i];
memset(dp,63,sizeof(dp));
memset(f,63,sizeof(f));
rep(i,1,n){
f[i][i-1][0]=0;
}
rep(len,1,n){
rep(l,1,n){
int r=l+len-1;
if(r>n)break;
if(l==r){
umin(dp[l][r],0);
}
if(len>=L&&len<=R){
umin(dp[l][r],sum[r]-sum[l-1]);
}
rep(i,l,r){
rep(k,1,R){
umin(f[l][r][k],f[l][i-1][k-1]+dp[i][r]);
if(k>=L){
umin(dp[l][r],f[l][r][k]+sum[r]-sum[l-1]);
}
}
}
}
}
printf("%d\n",dp[1][n]<1e9?dp[1][n]:0);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 8416kb
input:
3 2 2 1 2 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: 0
Accepted
time: 0ms
memory: 8484kb
input:
3 2 3 1 2 3
output:
6
result:
ok 1 number(s): "6"
Test #3:
score: 0
Accepted
time: 2ms
memory: 8408kb
input:
4 3 3 1 2 3 4
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: -100
Wrong Answer
time: 4ms
memory: 8368kb
input:
100 4 7 570 608 194 26 243 470 418 119 1000 936 440 302 797 155 676 283 869 60 959 793 158 397 808 656 379 316 485 854 753 280 543 435 756 822 106 561 402 347 99 739 8 682 834 549 812 32 338 765 699 575 575 785 171 504 335 113 284 612 276 518 835 677 865 900 687 48 859 179 343 318 626 812 523 11 400...
output:
122241
result:
wrong answer 1st numbers differ - expected: '120446', found: '122241'