#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int K;
cin>>K;
vector<int>v(K);
for(int i=0;i<K;i++){
cin>>v[i];
}
auto calc=[&](int n,int i)->int{
int x=0;
for(int p=1;p<=n;p*=K){
int xx=n/(p*K)*p+min(max(n%(p*K)-p*i,0ll),p);
x+=xx;
// int y=0;
// for(int nn=0;nn<n;nn++){
// if(nn%(p*K)/p==i)y++;
// }
// if(xx!=y){
// cout<<n<<' '<<i<<' '<<p<<' '<<xx<<' '<<y<<endl;
// exit(1);
// }
}
return x;
};
int l=1,h=1e10;
while(l<h){
int m=(l+h)/2;
int ok=1;
for(int i=0;i<K;i++){
ok&=calc(m,i)<=v[i];
}
if(ok){
l=m+1;
}
else{
h=m;
}
}
cout<<h<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Wrong answer | 3ms | 2020 KiB | ||||
3 | Wrong answer | 3ms | 2232 KiB | ||||
subtask2 | 0/25 | ||||||
4 | Wrong answer | 3ms | 2460 KiB | ||||
5 | Wrong answer | 3ms | 2688 KiB | ||||
6 | Wrong answer | 3ms | 2892 KiB | ||||
7 | Wrong answer | 3ms | 3080 KiB | ||||
8 | Wrong answer | 3ms | 3184 KiB | ||||
9 | Wrong answer | 3ms | 3260 KiB | ||||
10 | Wrong answer | 3ms | 3392 KiB | ||||
11 | Wrong answer | 3ms | 3604 KiB | ||||
12 | Wrong answer | 3ms | 3816 KiB | ||||
13 | Wrong answer | 3ms | 3900 KiB | ||||
14 | Wrong answer | 3ms | 3896 KiB | ||||
15 | Wrong answer | 2ms | 3904 KiB | ||||
16 | Wrong answer | 3ms | 3900 KiB | ||||
17 | Wrong answer | 3ms | 4028 KiB | ||||
18 | Wrong answer | 3ms | 4236 KiB | ||||
19 | Wrong answer | 3ms | 4340 KiB | ||||
subtask3 | 0/10 | ||||||
20 | Wrong answer | 3ms | 4420 KiB | ||||
21 | Wrong answer | 3ms | 4452 KiB | ||||
22 | Wrong answer | 3ms | 4548 KiB | ||||
23 | Wrong answer | 3ms | 4536 KiB | ||||
24 | Wrong answer | 3ms | 4636 KiB | ||||
subtask4 | 0/15 | ||||||
25 | Wrong answer | 3ms | 4636 KiB | ||||
26 | Wrong answer | 3ms | 4632 KiB | ||||
27 | Wrong answer | 3ms | 4908 KiB | ||||
28 | Wrong answer | 3ms | 4776 KiB | ||||
29 | Wrong answer | 3ms | 4772 KiB | ||||
30 | Accepted | 3ms | 4768 KiB | ||||
31 | Wrong answer | 3ms | 4720 KiB | ||||
32 | Wrong answer | 3ms | 4844 KiB | ||||
33 | Wrong answer | 3ms | 4836 KiB | ||||
subtask5 | 0/20 | ||||||
34 | Wrong answer | 3ms | 4920 KiB | ||||
35 | Accepted | 3ms | 4920 KiB | ||||
36 | Wrong answer | 3ms | 4924 KiB | ||||
37 | Wrong answer | 3ms | 5068 KiB | ||||
38 | Wrong answer | 3ms | 4952 KiB | ||||
39 | Wrong answer | 3ms | 5052 KiB | ||||
40 | Wrong answer | 3ms | 5052 KiB | ||||
41 | Wrong answer | 3ms | 5032 KiB | ||||
42 | Wrong answer | 3ms | 5128 KiB | ||||
subtask6 | 0/30 | ||||||
43 | Wrong answer | 3ms | 5128 KiB | ||||
44 | Wrong answer | 3ms | 4932 KiB | ||||
45 | Wrong answer | 3ms | 5032 KiB | ||||
46 | Wrong answer | 3ms | 5036 KiB | ||||
47 | Wrong answer | 3ms | 5060 KiB | ||||
48 | Wrong answer | 2ms | 5032 KiB | ||||
49 | Wrong answer | 3ms | 5136 KiB | ||||
50 | Wrong answer | 3ms | 5132 KiB | ||||
51 | Wrong answer | 3ms | 5132 KiB | ||||
52 | Wrong answer | 3ms | 5348 KiB | ||||
53 | Wrong answer | 2ms | 5172 KiB | ||||
54 | Wrong answer | 3ms | 5328 KiB | ||||
55 | Wrong answer | 3ms | 5288 KiB | ||||
56 | Wrong answer | 3ms | 5284 KiB | ||||
57 | Wrong answer | 3ms | 5284 KiB | ||||
58 | Wrong answer | 3ms | 5284 KiB | ||||
59 | Wrong answer | 3ms | 5284 KiB | ||||
60 | Wrong answer | 3ms | 5292 KiB |