101652024-03-28 22:43:41111Házszámokcpp17Wrong answer 0/1003ms5348 KiB
#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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1828 KiB
2Wrong answer3ms2020 KiB
3Wrong answer3ms2232 KiB
subtask20/25
4Wrong answer3ms2460 KiB
5Wrong answer3ms2688 KiB
6Wrong answer3ms2892 KiB
7Wrong answer3ms3080 KiB
8Wrong answer3ms3184 KiB
9Wrong answer3ms3260 KiB
10Wrong answer3ms3392 KiB
11Wrong answer3ms3604 KiB
12Wrong answer3ms3816 KiB
13Wrong answer3ms3900 KiB
14Wrong answer3ms3896 KiB
15Wrong answer2ms3904 KiB
16Wrong answer3ms3900 KiB
17Wrong answer3ms4028 KiB
18Wrong answer3ms4236 KiB
19Wrong answer3ms4340 KiB
subtask30/10
20Wrong answer3ms4420 KiB
21Wrong answer3ms4452 KiB
22Wrong answer3ms4548 KiB
23Wrong answer3ms4536 KiB
24Wrong answer3ms4636 KiB
subtask40/15
25Wrong answer3ms4636 KiB
26Wrong answer3ms4632 KiB
27Wrong answer3ms4908 KiB
28Wrong answer3ms4776 KiB
29Wrong answer3ms4772 KiB
30Accepted3ms4768 KiB
31Wrong answer3ms4720 KiB
32Wrong answer3ms4844 KiB
33Wrong answer3ms4836 KiB
subtask50/20
34Wrong answer3ms4920 KiB
35Accepted3ms4920 KiB
36Wrong answer3ms4924 KiB
37Wrong answer3ms5068 KiB
38Wrong answer3ms4952 KiB
39Wrong answer3ms5052 KiB
40Wrong answer3ms5052 KiB
41Wrong answer3ms5032 KiB
42Wrong answer3ms5128 KiB
subtask60/30
43Wrong answer3ms5128 KiB
44Wrong answer3ms4932 KiB
45Wrong answer3ms5032 KiB
46Wrong answer3ms5036 KiB
47Wrong answer3ms5060 KiB
48Wrong answer2ms5032 KiB
49Wrong answer3ms5136 KiB
50Wrong answer3ms5132 KiB
51Wrong answer3ms5132 KiB
52Wrong answer3ms5348 KiB
53Wrong answer2ms5172 KiB
54Wrong answer3ms5328 KiB
55Wrong answer3ms5288 KiB
56Wrong answer3ms5284 KiB
57Wrong answer3ms5284 KiB
58Wrong answer3ms5284 KiB
59Wrong answer3ms5284 KiB
60Wrong answer3ms5292 KiB