ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#212811 | #3830. D | xxc | 5 | 8ms | 1244kb | C++ | 1.3kb | 2024-10-20 11:45:25 | 2024-10-20 12:45:29 |
answer
#include<iostream>
#include<vector>
using namespace std;
vector<long long> v;
vector<long long> t;
long long n,m,k;
long long mypow(long long a,long long p)
{
long long res=1;
for(int i=1;i<=p;i++)
{
res*=a;
}
return res;
}
bool check(long long x,long long l)
{
//cout<<endl<<x<<endl<<l<<endl;
//for(auto i:v)
//{
// cout<<i<<' ';
//}
//cout<<endl;
//for(auto i:t)
//{
// cout<<i<<' ';
//}
//cout<<endl;
if(l==m)
{
for(int i=1;i<=n;i++)
{
if(t[i]<v[i])
{
return false;
}
}
return true;
}
for(int i=1;i<=n;i++)
{
for(int j=i;j<=min(i+x,n);j++)
{
long long add=mypow(x-j+i,k);
t[j]+=add;
}
if(check(x,l+1))
{
return true;
}
for(int j=i;j<=min(i+x,n);j++)
{
long long add=mypow(x-j+i,k);
t[j]-=add;
}
}
return false;
}
int main()
{
cin>>n>>m>>k;
v.assign(n+2,0);
for(int i=1;i<=n;i++)
{
cin>>v[i];
}
//for(auto i:v)
//{
// cout<<i<<' ';
//}
//cout<<endl<<endl;
long long l=1,r=1000000;
//long long l=1,r=24;
while(l<=r)
{
t.clear();
t.assign(n+2,0);
long long mid=(l+r)/2;
if(check(mid,0))
{
r=mid-1;
}else
{
l=mid+1;
}
}
if(l==1000001)
{
cout<<-1<<endl;
}else
{
cout<<r+1<<endl;
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 1232kb
input:
5 2 0 1 4 2 4 2
output:
-1
result:
ok 1 number(s): "-1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 1228kb
input:
5 4 0 3 3 3 2 4
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 1232kb
input:
5 3 0 5 2 2 4 2
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 1228kb
input:
5 5 0 5 4 1 3 2
output:
4
result:
ok 1 number(s): "4"
Test #5:
score: 0
Accepted
time: 1ms
memory: 1232kb
input:
5 2 0 5 4 2 4 4
output:
-1
result:
ok 1 number(s): "-1"
Subtask #2:
score: 0
Time Limit Exceeded
Test #6:
score: 0
Time Limit Exceeded
input:
100000 3 0 55571 62024 7086 67802 12577 42004 72323 45260 40287 39641 64847 42428 20318 80027 1675 1...
output:
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #11:
score: 10
Accepted
time: 7ms
memory: 1244kb
input:
1000 1 1 993 705 891 648 406 9 983 913 370 408 607 47 85 199 767 448 723 255 253 302 754 135 641 726...
output:
1991
result:
ok 1 number(s): "1991"
Test #12:
score: -10
Time Limit Exceeded
input:
1000 529 1 321 273 256 430 151 307 590 682 756 267 100 169 963 681 121 604 781 631 573 463 50 114 36...
output:
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #16:
score: 0
Time Limit Exceeded
input:
100000 4 1 10156 27005 39480 62054 63362 28009 65831 14391 93683 7991 17027 26313 1403 15929 30567 1...
output:
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #21:
score: 0
Time Limit Exceeded
input:
1000 169 2 853 394 985 195 859 84 227 50 641 365 409 407 845 112 7 582 920 965 590 869 550 781 40 44...
output:
result:
Subtask #6:
score: 0
Time Limit Exceeded
Test #26:
score: 0
Time Limit Exceeded
input:
100000 31778 2 9482 16920 65207 41338 19891 97532 56865 946 56851 5908 19270 8065 53369 97241 69805 ...