#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];
}
v[0]++;
auto calc=[&](int n,int i)->int{
int x=0;
for(int p=1;p<=n;p*=K){
int xx=n/(p*K)*p+(i==0?0:min(max(n%(p*K)-p*i,0ll),p));
x+=xx;
}
return x;
};
int l=1,h=1e6;
while(l<h){
int m=(l+h)/2;
int ok=1;
for(int i=0;i<K;i++){
ok&=calc(m+1,i)<=v[i];
}
if(ok){
l=m+1;
}
else{
h=m;
}
}
cout<<h-1<<'\n';
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1972 KiB | ||||
2 | Accepted | 3ms | 2112 KiB | ||||
3 | Wrong answer | 3ms | 2244 KiB | ||||
subtask2 | 0/25 | ||||||
4 | Wrong answer | 2ms | 2288 KiB | ||||
5 | Wrong answer | 2ms | 2280 KiB | ||||
6 | Wrong answer | 3ms | 2420 KiB | ||||
7 | Wrong answer | 3ms | 2652 KiB | ||||
8 | Accepted | 3ms | 2844 KiB | ||||
9 | Accepted | 3ms | 2928 KiB | ||||
10 | Wrong answer | 3ms | 3060 KiB | ||||
11 | Wrong answer | 3ms | 3140 KiB | ||||
12 | Accepted | 3ms | 3244 KiB | ||||
13 | Wrong answer | 3ms | 3280 KiB | ||||
14 | Accepted | 3ms | 3504 KiB | ||||
15 | Wrong answer | 3ms | 3672 KiB | ||||
16 | Wrong answer | 3ms | 3768 KiB | ||||
17 | Wrong answer | 3ms | 3772 KiB | ||||
18 | Wrong answer | 3ms | 3900 KiB | ||||
19 | Wrong answer | 3ms | 4100 KiB | ||||
subtask3 | 0/10 | ||||||
20 | Wrong answer | 3ms | 4080 KiB | ||||
21 | Wrong answer | 2ms | 4060 KiB | ||||
22 | Wrong answer | 2ms | 4056 KiB | ||||
23 | Accepted | 3ms | 4436 KiB | ||||
24 | Wrong answer | 3ms | 4072 KiB | ||||
subtask4 | 0/15 | ||||||
25 | Wrong answer | 3ms | 4296 KiB | ||||
26 | Wrong answer | 2ms | 4504 KiB | ||||
27 | Wrong answer | 3ms | 4736 KiB | ||||
28 | Wrong answer | 3ms | 4956 KiB | ||||
29 | Wrong answer | 3ms | 5008 KiB | ||||
30 | Accepted | 3ms | 4912 KiB | ||||
31 | Wrong answer | 3ms | 5004 KiB | ||||
32 | Wrong answer | 3ms | 5036 KiB | ||||
33 | Wrong answer | 3ms | 5160 KiB | ||||
subtask5 | 0/20 | ||||||
34 | Accepted | 3ms | 5132 KiB | ||||
35 | Accepted | 3ms | 5120 KiB | ||||
36 | Wrong answer | 3ms | 5116 KiB | ||||
37 | Wrong answer | 3ms | 5220 KiB | ||||
38 | Wrong answer | 3ms | 5332 KiB | ||||
39 | Wrong answer | 3ms | 5332 KiB | ||||
40 | Wrong answer | 3ms | 5372 KiB | ||||
41 | Wrong answer | 3ms | 5344 KiB | ||||
42 | Wrong answer | 3ms | 5220 KiB | ||||
subtask6 | 0/30 | ||||||
43 | Wrong answer | 3ms | 5120 KiB | ||||
44 | Wrong answer | 3ms | 5116 KiB | ||||
45 | Wrong answer | 3ms | 5116 KiB | ||||
46 | Wrong answer | 3ms | 5264 KiB | ||||
47 | Wrong answer | 3ms | 5244 KiB | ||||
48 | Wrong answer | 3ms | 5220 KiB | ||||
49 | Wrong answer | 3ms | 5232 KiB | ||||
50 | Wrong answer | 3ms | 5228 KiB | ||||
51 | Wrong answer | 3ms | 5228 KiB | ||||
52 | Wrong answer | 3ms | 5324 KiB | ||||
53 | Wrong answer | 3ms | 5140 KiB | ||||
54 | Wrong answer | 3ms | 5140 KiB | ||||
55 | Wrong answer | 3ms | 5264 KiB | ||||
56 | Wrong answer | 3ms | 5140 KiB | ||||
57 | Wrong answer | 3ms | 5240 KiB | ||||
58 | Wrong answer | 3ms | 5136 KiB | ||||
59 | Wrong answer | 3ms | 5292 KiB | ||||
60 | Wrong answer | 3ms | 5248 KiB |