QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103472 | #5822. 城市建设 | sichengzhou | 40 | 3ms | 3840kb | C++14 | 503b | 2023-05-06 02:41:09 | 2023-05-06 02:41:12 |
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-1,y=x/2,z=x-y;
f[i]=min(f[i],c+f[j]+(LL)y*(y+1)/2+(LL)z*(z+1)/2+i-j);
}
// 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: 5
Accepted
time: 2ms
memory: 3840kb
input:
14 7
output:
45
result:
ok single line: '45'
Test #2:
score: 5
Accepted
time: 1ms
memory: 3588kb
input:
15 9
output:
53
result:
ok single line: '53'
Test #3:
score: 5
Accepted
time: 2ms
memory: 3584kb
input:
15 32
output:
88
result:
ok single line: '88'
Test #4:
score: 5
Accepted
time: 0ms
memory: 3580kb
input:
18 47
output:
128
result:
ok single line: '128'
Test #5:
score: 5
Accepted
time: 3ms
memory: 3620kb
input:
691 13
output:
3152
result:
ok single line: '3152'
Test #6:
score: 5
Accepted
time: 2ms
memory: 3580kb
input:
723 381
output:
14800
result:
ok single line: '14800'
Test #7:
score: 5
Accepted
time: 2ms
memory: 3776kb
input:
530 4577
output:
36261
result:
ok single line: '36261'
Test #8:
score: 5
Accepted
time: 3ms
memory: 3556kb
input:
873 71661
output:
239024
result:
ok single line: '239024'
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