101662024-03-28 22:55:35111Házszámokcpp17Wrong answer 0/1003ms5372 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];
	}
	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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1972 KiB
2Accepted3ms2112 KiB
3Wrong answer3ms2244 KiB
subtask20/25
4Wrong answer2ms2288 KiB
5Wrong answer2ms2280 KiB
6Wrong answer3ms2420 KiB
7Wrong answer3ms2652 KiB
8Accepted3ms2844 KiB
9Accepted3ms2928 KiB
10Wrong answer3ms3060 KiB
11Wrong answer3ms3140 KiB
12Accepted3ms3244 KiB
13Wrong answer3ms3280 KiB
14Accepted3ms3504 KiB
15Wrong answer3ms3672 KiB
16Wrong answer3ms3768 KiB
17Wrong answer3ms3772 KiB
18Wrong answer3ms3900 KiB
19Wrong answer3ms4100 KiB
subtask30/10
20Wrong answer3ms4080 KiB
21Wrong answer2ms4060 KiB
22Wrong answer2ms4056 KiB
23Accepted3ms4436 KiB
24Wrong answer3ms4072 KiB
subtask40/15
25Wrong answer3ms4296 KiB
26Wrong answer2ms4504 KiB
27Wrong answer3ms4736 KiB
28Wrong answer3ms4956 KiB
29Wrong answer3ms5008 KiB
30Accepted3ms4912 KiB
31Wrong answer3ms5004 KiB
32Wrong answer3ms5036 KiB
33Wrong answer3ms5160 KiB
subtask50/20
34Accepted3ms5132 KiB
35Accepted3ms5120 KiB
36Wrong answer3ms5116 KiB
37Wrong answer3ms5220 KiB
38Wrong answer3ms5332 KiB
39Wrong answer3ms5332 KiB
40Wrong answer3ms5372 KiB
41Wrong answer3ms5344 KiB
42Wrong answer3ms5220 KiB
subtask60/30
43Wrong answer3ms5120 KiB
44Wrong answer3ms5116 KiB
45Wrong answer3ms5116 KiB
46Wrong answer3ms5264 KiB
47Wrong answer3ms5244 KiB
48Wrong answer3ms5220 KiB
49Wrong answer3ms5232 KiB
50Wrong answer3ms5228 KiB
51Wrong answer3ms5228 KiB
52Wrong answer3ms5324 KiB
53Wrong answer3ms5140 KiB
54Wrong answer3ms5140 KiB
55Wrong answer3ms5264 KiB
56Wrong answer3ms5140 KiB
57Wrong answer3ms5240 KiB
58Wrong answer3ms5136 KiB
59Wrong answer3ms5292 KiB
60Wrong answer3ms5248 KiB