101642024-03-28 22:35:50111Házszámokcpp17Wrong answer 0/1003ms5192 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){
			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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1832 KiB
2Wrong answer3ms2044 KiB
3Wrong answer3ms2280 KiB
subtask20/25
4Wrong answer3ms2456 KiB
5Wrong answer3ms2540 KiB
6Wrong answer3ms2544 KiB
7Wrong answer3ms2556 KiB
8Wrong answer3ms2832 KiB
9Wrong answer3ms3016 KiB
10Wrong answer3ms3236 KiB
11Wrong answer3ms3360 KiB
12Wrong answer3ms3428 KiB
13Wrong answer3ms3424 KiB
14Wrong answer3ms3528 KiB
15Wrong answer3ms3872 KiB
16Wrong answer3ms4080 KiB
17Wrong answer3ms4064 KiB
18Wrong answer3ms4184 KiB
19Wrong answer3ms4188 KiB
subtask30/10
20Wrong answer3ms4256 KiB
21Wrong answer3ms4256 KiB
22Wrong answer3ms4540 KiB
23Wrong answer3ms4308 KiB
24Wrong answer3ms4396 KiB
subtask40/15
25Wrong answer3ms4316 KiB
26Wrong answer3ms4316 KiB
27Wrong answer3ms4568 KiB
28Wrong answer3ms4420 KiB
29Wrong answer3ms4332 KiB
30Accepted3ms4460 KiB
31Wrong answer3ms4560 KiB
32Wrong answer3ms4564 KiB
33Wrong answer3ms4780 KiB
subtask50/20
34Wrong answer3ms4780 KiB
35Accepted3ms4760 KiB
36Wrong answer3ms4768 KiB
37Wrong answer3ms4868 KiB
38Wrong answer3ms4768 KiB
39Wrong answer3ms4776 KiB
40Wrong answer3ms4784 KiB
41Wrong answer3ms4784 KiB
42Wrong answer3ms4788 KiB
subtask60/30
43Wrong answer3ms4888 KiB
44Wrong answer3ms4700 KiB
45Wrong answer3ms4800 KiB
46Wrong answer3ms4704 KiB
47Wrong answer3ms4812 KiB
48Wrong answer3ms4712 KiB
49Wrong answer3ms4720 KiB
50Wrong answer3ms4724 KiB
51Wrong answer3ms4952 KiB
52Wrong answer3ms4944 KiB
53Wrong answer3ms4948 KiB
54Wrong answer3ms4948 KiB
55Wrong answer3ms5076 KiB
56Wrong answer3ms4960 KiB
57Wrong answer3ms4960 KiB
58Wrong answer3ms5092 KiB
59Wrong answer3ms5180 KiB
60Wrong answer3ms5192 KiB