#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){
x+=n/(p*K)*p;
x+=min(max(n%(p*K)-n/(p*K)*p*i,0ll),p);
}
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 | 1832 KiB | ||||
2 | Wrong answer | 3ms | 2044 KiB | ||||
3 | Wrong answer | 3ms | 2280 KiB | ||||
subtask2 | 0/25 | ||||||
4 | Wrong answer | 3ms | 2456 KiB | ||||
5 | Wrong answer | 3ms | 2540 KiB | ||||
6 | Wrong answer | 3ms | 2544 KiB | ||||
7 | Wrong answer | 3ms | 2556 KiB | ||||
8 | Wrong answer | 3ms | 2832 KiB | ||||
9 | Wrong answer | 3ms | 3016 KiB | ||||
10 | Wrong answer | 3ms | 3236 KiB | ||||
11 | Wrong answer | 3ms | 3360 KiB | ||||
12 | Wrong answer | 3ms | 3428 KiB | ||||
13 | Wrong answer | 3ms | 3424 KiB | ||||
14 | Wrong answer | 3ms | 3528 KiB | ||||
15 | Wrong answer | 3ms | 3872 KiB | ||||
16 | Wrong answer | 3ms | 4080 KiB | ||||
17 | Wrong answer | 3ms | 4064 KiB | ||||
18 | Wrong answer | 3ms | 4184 KiB | ||||
19 | Wrong answer | 3ms | 4188 KiB | ||||
subtask3 | 0/10 | ||||||
20 | Wrong answer | 3ms | 4256 KiB | ||||
21 | Wrong answer | 3ms | 4256 KiB | ||||
22 | Wrong answer | 3ms | 4540 KiB | ||||
23 | Wrong answer | 3ms | 4308 KiB | ||||
24 | Wrong answer | 3ms | 4396 KiB | ||||
subtask4 | 0/15 | ||||||
25 | Wrong answer | 3ms | 4316 KiB | ||||
26 | Wrong answer | 3ms | 4316 KiB | ||||
27 | Wrong answer | 3ms | 4568 KiB | ||||
28 | Wrong answer | 3ms | 4420 KiB | ||||
29 | Wrong answer | 3ms | 4332 KiB | ||||
30 | Accepted | 3ms | 4460 KiB | ||||
31 | Wrong answer | 3ms | 4560 KiB | ||||
32 | Wrong answer | 3ms | 4564 KiB | ||||
33 | Wrong answer | 3ms | 4780 KiB | ||||
subtask5 | 0/20 | ||||||
34 | Wrong answer | 3ms | 4780 KiB | ||||
35 | Accepted | 3ms | 4760 KiB | ||||
36 | Wrong answer | 3ms | 4768 KiB | ||||
37 | Wrong answer | 3ms | 4868 KiB | ||||
38 | Wrong answer | 3ms | 4768 KiB | ||||
39 | Wrong answer | 3ms | 4776 KiB | ||||
40 | Wrong answer | 3ms | 4784 KiB | ||||
41 | Wrong answer | 3ms | 4784 KiB | ||||
42 | Wrong answer | 3ms | 4788 KiB | ||||
subtask6 | 0/30 | ||||||
43 | Wrong answer | 3ms | 4888 KiB | ||||
44 | Wrong answer | 3ms | 4700 KiB | ||||
45 | Wrong answer | 3ms | 4800 KiB | ||||
46 | Wrong answer | 3ms | 4704 KiB | ||||
47 | Wrong answer | 3ms | 4812 KiB | ||||
48 | Wrong answer | 3ms | 4712 KiB | ||||
49 | Wrong answer | 3ms | 4720 KiB | ||||
50 | Wrong answer | 3ms | 4724 KiB | ||||
51 | Wrong answer | 3ms | 4952 KiB | ||||
52 | Wrong answer | 3ms | 4944 KiB | ||||
53 | Wrong answer | 3ms | 4948 KiB | ||||
54 | Wrong answer | 3ms | 4948 KiB | ||||
55 | Wrong answer | 3ms | 5076 KiB | ||||
56 | Wrong answer | 3ms | 4960 KiB | ||||
57 | Wrong answer | 3ms | 4960 KiB | ||||
58 | Wrong answer | 3ms | 5092 KiB | ||||
59 | Wrong answer | 3ms | 5180 KiB | ||||
60 | Wrong answer | 3ms | 5192 KiB |