QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103471 | #5822. 城市建设 | sichengzhou | 10 | 3ms | 3836kb | C++14 | 497b | 2023-05-06 02:39:12 | 2023-05-06 02:39:13 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1e3+3;
int n,c;
LL f[N];
int main()
{
scanf("%d%d",&n,&c);
if(n==1)
{
printf("0\n");
return 0;
}
LL ans=4e18;
for(int i=1;i<=n;i++)
{
f[i]=c+(LL)i*(i-1)/2;
for(int j=1;j<i;j++)
{
int x=i-j,y=x/2,z=x-y;
f[i]=min(f[i],c+f[j]+(LL)y*(y+1)/2+(LL)z*(z+1)/2);
}
// cout<<i<<' '<<f[i]<<endl;
ans=min(ans,f[i]+(LL)(n-i)*(n-i+1)/2);
}
printf("%lld\n",ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3580kb
input:
14 7
output:
42
result:
wrong answer 1st lines differ - expected: '45', found: '42'
Test #2:
score: 0
Wrong Answer
time: 2ms
memory: 3568kb
input:
15 9
output:
50
result:
wrong answer 1st lines differ - expected: '53', found: '50'
Test #3:
score: 5
Accepted
time: 0ms
memory: 3564kb
input:
15 32
output:
88
result:
ok single line: '88'
Test #4:
score: 5
Accepted
time: 2ms
memory: 3572kb
input:
18 47
output:
128
result:
ok single line: '128'
Test #5:
score: 0
Wrong Answer
time: 3ms
memory: 3836kb
input:
691 13
output:
2847
result:
wrong answer 1st lines differ - expected: '3152', found: '2847'
Test #6:
score: 0
Wrong Answer
time: 3ms
memory: 3816kb
input:
723 381
output:
14459
result:
wrong answer 1st lines differ - expected: '14800', found: '14459'
Test #7:
score: 0
Wrong Answer
time: 1ms
memory: 3600kb
input:
530 4577
output:
36063
result:
wrong answer 1st lines differ - expected: '36261', found: '36063'
Test #8:
score: 0
Wrong Answer
time: 2ms
memory: 3596kb
input:
873 71661
output:
238806
result:
wrong answer 1st lines differ - expected: '239024', found: '238806'
Test #9:
score: 0
Runtime Error
input:
50512 6380
output:
result:
Test #10:
score: 0
Runtime Error
input:
94371 8943
output:
result:
Test #11:
score: 0
Runtime Error
input:
51969 2391
output:
result:
Test #12:
score: 0
Runtime Error
input:
90967 8394
output:
result:
Test #13:
score: 0
Runtime Error
input:
903367404 61
output:
result:
Test #14:
score: 0
Runtime Error
input:
619459664 4190
output:
result:
Test #15:
score: 0
Runtime Error
input:
714829312 304390
output:
result:
Test #16:
score: 0
Runtime Error
input:
760183494 45248537
output:
result:
Test #17:
score: 0
Runtime Error
input:
500350887 499
output:
result:
Test #18:
score: 0
Runtime Error
input:
837064072 96455
output:
result:
Test #19:
score: 0
Runtime Error
input:
784256648 6177252
output:
result:
Test #20:
score: 0
Runtime Error
input:
650371022 480071734