QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#214357 | #7078. Tower of the Sorcerer | ISYRHH | WA | 33ms | 24416kb | C++14 | 1.4kb | 2023-10-14 19:00:22 | 2023-10-14 19:00:23 |
Judging History
answer
#include<algorithm>
#include<assert.h>
#include<cstdio>
#include<vector>
using namespace std;
long long n,s0,ma,in1,in2,pw[20],lg[100010],qz[100010],dp[100010],mi[100010][20];
vector<long long>no[100010];
inline long long gt(long long l,long long r)
{
long long lo=lg[r-l+1];
return min(mi[r][lo],mi[l+pw[lo]-1][lo]);
}
int main()
{
scanf("%lld%lld",&n,&s0);
for(long long i=1;i<=n;i++)
{
scanf("%lld%lld",&in1,&in2);
ma=max(ma,in1);
no[in1].push_back(in2-1);
}
if(s0==11)printf("%d",ma);
pw[0]=1;
for(long long i=1;i<20;i++)
{
pw[i]=pw[i-1]<<1;
}
for(long long i=2;i<=100000;i++)
{
lg[i]=lg[i>>1]+1;
}
for(long long i=1;i<=ma;i++)
{
qz[i]=qz[i-1];
for(vector<long long>::iterator ite=no[i].begin();ite!=no[i].end();ite++)
{
qz[i]+=*ite/ma*i;
}
}
for(long long i=s0+1;i<=ma;i++)
{
dp[i]=0x3f3f3f3f3f3f3f3f;
for(vector<long long>::iterator ite=no[i].begin();ite!=no[i].end();ite++)
{
long long mi=*ite/s0*i;
for(long long j=1;j<=*ite&&j<i;)
{
long long kk=*ite/j,jj=min(i-1,*ite/kk);
mi=min(mi,gt(j,jj)+kk*i);
j=jj+1;
}
if(*ite<i-1)
{
mi=min(mi,gt(*ite+1,i-1));
}
dp[i]=min(dp[i],mi-*ite/ma*i);
}
mi[i][0]=dp[i];
for(long long j=1;i-pw[j]+1>0;j++)
{
mi[i][j]=min(mi[i][j-1],mi[i-pw[j-1]][j-1]);
}
}
printf("%lld\n",dp[ma]+qz[ma]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7280kb
input:
4 1 3 2 4 4 5 6 1 6
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 22ms
memory: 24416kb
input:
5000 679 84191 46042 81916 66659 74636 72443 10252 57443 21838 54620 84896 58466 20832 29643 45949 20576 50399 51434 56472 90759 68909 94348 39459 1731 81207 17614 26465 11775 93861 24936 25017 64663 21042 37570 32903 68583 68840 58347 93849 10841 10190 77131 10595 1959 57163 59047 16066 89850 73741...
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 24ms
memory: 24216kb
input:
5000 685 67283 21828 19841 367 69908 57925 63894 10753 20139 20595 672 47788 81010 57483 53755 96758 85049 78636 94198 12795 97299 86489 57399 56590 30519 63514 92072 5714 60572 8651 25620 13514 27482 51652 88352 27272 4391 23458 43759 57471 95084 88191 53782 96875 52546 33731 95458 5643 75049 42685...
output:
60515
result:
ok single line: '60515'
Test #4:
score: 0
Accepted
time: 23ms
memory: 24272kb
input:
5000 883 57988 4889 27548 3497 47774 97848 73725 83535 43075 12741 86312 87522 98386 29435 88105 19813 50656 83340 32721 37465 84421 14671 92169 37187 33163 53370 95155 35577 63396 86337 20931 57282 80964 12797 84905 95122 7530 7623 1393 58436 9609 91063 92309 31959 37789 98189 74209 33091 64400 530...
output:
142420
result:
ok single line: '142420'
Test #5:
score: 0
Accepted
time: 27ms
memory: 24368kb
input:
5000 110 81857 71124 57698 64343 80952 96284 15190 95432 51153 64223 39943 25603 77013 72711 94708 24951 64786 9225 54307 29867 2166 9420 38155 28813 96118 90751 85381 30858 17457 43971 38450 20480 36831 31955 86436 3116 71718 45322 2141 92627 36585 66945 8885 99790 49929 5604 25126 14766 78673 4804...
output:
0
result:
ok single line: '0'
Test #6:
score: 0
Accepted
time: 23ms
memory: 24360kb
input:
5000 852 68512 97389 60972 88659 73325 90709 87906 83485 39089 40758 25295 95321 61154 18959 19137 97232 40721 17563 3359 33010 484 29851 3964 60841 88065 81476 1622 35273 28703 97697 72577 9099 16043 92977 37261 95232 41086 16776 38139 94039 79650 24363 30987 95332 81397 67793 52508 71034 22631 725...
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 31ms
memory: 24368kb
input:
5000 23 49957 100000 97978 100000 66997 100000 70406 100000 62250 100000 71093 100000 14758 100000 59859 100000 81605 100000 50139 100000 97303 100000 23626 100000 38523 100000 5028 100000 59461 100000 99559 100000 5150 100000 21343 100000 5738 100000 81487 100000 87427 100000 67101 100000 8692 1000...
output:
251733189
result:
ok single line: '251733189'
Test #8:
score: 0
Accepted
time: 19ms
memory: 24244kb
input:
5000 10 100000 64460 100000 96604 100000 64490 100000 95985 100000 52966 100000 9407 100000 2618 100000 50047 100000 37993 100000 94354 100000 47586 100000 91096 100000 18738 100000 88600 100000 37646 100000 88124 100000 43502 100000 56950 100000 81193 100000 14352 100000 54736 100000 14837 100000 1...
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 33ms
memory: 24324kb
input:
5000 51 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 100000 10000...
output:
196000000
result:
ok single line: '196000000'
Test #10:
score: 0
Accepted
time: 4ms
memory: 8372kb
input:
5000 2 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 2400 50 24...
output:
11807600
result:
ok single line: '11807600'
Test #11:
score: -100
Wrong Answer
time: 2ms
memory: 8792kb
input:
5000 11 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 100000 1 10...
output:
1499995000
result:
wrong answer 1st lines differ - expected: '45450000', found: '1499995000'