101672024-03-28 22:56:01111Házszámokcpp17Wrong answer 25/1003ms5236 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=1e17;
	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
1Accepted3ms1832 KiB
2Accepted3ms2056 KiB
3Wrong answer3ms2244 KiB
subtask20/25
4Wrong answer3ms2452 KiB
5Wrong answer3ms2668 KiB
6Wrong answer3ms2872 KiB
7Wrong answer3ms3232 KiB
8Accepted3ms3408 KiB
9Accepted3ms3400 KiB
10Wrong answer3ms3372 KiB
11Wrong answer3ms3740 KiB
12Accepted3ms3692 KiB
13Wrong answer3ms3720 KiB
14Accepted3ms3796 KiB
15Wrong answer3ms3876 KiB
16Wrong answer3ms3868 KiB
17Wrong answer3ms3972 KiB
18Wrong answer3ms3876 KiB
19Wrong answer3ms3872 KiB
subtask310/10
20Accepted3ms3872 KiB
21Accepted3ms3872 KiB
22Accepted3ms4096 KiB
23Accepted3ms4104 KiB
24Accepted3ms4104 KiB
subtask415/15
25Accepted3ms4100 KiB
26Accepted3ms4208 KiB
27Accepted3ms4216 KiB
28Accepted3ms4088 KiB
29Accepted3ms4196 KiB
30Accepted3ms4328 KiB
31Accepted3ms4428 KiB
32Accepted3ms4432 KiB
33Accepted3ms4520 KiB
subtask50/20
34Accepted3ms4516 KiB
35Accepted3ms4516 KiB
36Wrong answer3ms4528 KiB
37Wrong answer3ms4624 KiB
38Accepted3ms4628 KiB
39Accepted3ms4628 KiB
40Accepted3ms4728 KiB
41Accepted3ms4880 KiB
42Wrong answer3ms4836 KiB
subtask60/30
43Wrong answer3ms4864 KiB
44Wrong answer3ms4872 KiB
45Wrong answer3ms4920 KiB
46Wrong answer3ms5036 KiB
47Wrong answer3ms4744 KiB
48Wrong answer3ms4748 KiB
49Wrong answer3ms4852 KiB
50Wrong answer3ms4976 KiB
51Accepted3ms4976 KiB
52Wrong answer3ms5048 KiB
53Wrong answer3ms5228 KiB
54Wrong answer3ms5236 KiB
55Wrong answer3ms5092 KiB
56Wrong answer3ms5104 KiB
57Wrong answer3ms5192 KiB
58Accepted3ms5100 KiB
59Wrong answer3ms5096 KiB
60Wrong answer3ms5128 KiB