253902026-02-19 18:43:17PajerLeviSzitakötő (50 pont)cpp17Runtime error 13/50591ms64000 KiB
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	vector<int> w_og(n); for(int& x : w_og) cin >> x;
	int ans=0;
	for(int bm=0;bm<(1<<n);bm++){
		//printf("{%X %x}", bm, 0b1010);
		vector<array<int, 3>> pq;
		vector<bool> eaten(n, false);
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				int dirI=(bm>>i)&1, dirJ=(bm>>j)&1;
				if(dirI==1 && dirJ==0) pq.push_back({j-i, i, j});
				if(dirI==1 && dirJ==1) pq.push_back({2*(n-j)+j-i, i, j});
				if(dirI==0 && dirJ==0) pq.push_back({2*(i+1)+j-i, i, j});
				if(dirI==0 && dirJ==1) pq.push_back({2*(n+1)+j-i, i, j});
			}
		}
		sort(pq.begin(), pq.end());
		vector<int> w=w_og;
		for(auto [x, a, b] : pq){
			if(!eaten[a] && !eaten[b]){
				//printf("[%d %d %d]", x, a, b);
				if(w[a]<w[b]){
					eaten[a]=true;
					w[b]+=w[a];
				}
				else if(w[b]<w[a]){
					eaten[b]=true;
					w[a]+=w[b];
				}
				else if(a<b){
					eaten[a]=true;
					w[b]+=w[a];
				}
				else{
					eaten[b]=true;
					w[a]+=w[b];
				}
			}
		}
		//printf("\n");
		ans+=!eaten[k-1];
	}
	printf("%d", ans);
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base13/50
1Accepted0/01ms332 KiB
2Runtime error0/0202ms64000 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted1/11ms508 KiB
6Accepted1/11ms316 KiB
7Accepted1/11ms316 KiB
8Accepted1/1337ms400 KiB
9Accepted1/1337ms404 KiB
10Accepted2/2337ms400 KiB
11Accepted2/2337ms400 KiB
12Accepted2/2337ms508 KiB
13Time limit exceeded0/2587ms12424 KiB
14Time limit exceeded0/2589ms12340 KiB
15Time limit exceeded0/2588ms12340 KiB
16Time limit exceeded0/2582ms12424 KiB
17Time limit exceeded0/2583ms12356 KiB
18Time limit exceeded0/2584ms12404 KiB
19Time limit exceeded0/2591ms12340 KiB
20Time limit exceeded0/2578ms12352 KiB
21Time limit exceeded0/1578ms12340 KiB
22Runtime error0/2165ms64000 KiB
23Runtime error0/2166ms64000 KiB
24Runtime error0/2204ms64000 KiB
25Runtime error0/2206ms64000 KiB
26Runtime error0/2180ms64000 KiB
27Runtime error0/2150ms64000 KiB
28Runtime error0/2195ms64000 KiB
29Runtime error0/2192ms64000 KiB
30Runtime error0/2206ms64000 KiB
31Runtime error0/2173ms64000 KiB