Submission #1253898

#TimeUsernameProblemLanguageResultExecution timeMemory
1253898chr34Festival (IOI25_festival)C++20
0 / 100
1096 ms33332 KiB
#include <bits/stdc++.h>

using namespace std;

//#define int long long
#define endl "\n"
#define dbg(x) cout << #x << " = " << (x) << endl;
//const int INF = 1e18;
const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;

int cnt = 0;
vector<int> best_path;

void dfs(int a, vector<bool> &used, vector<int> p, vector<int> t, vector<int> &path){
	bool progressed = false;
	int n = p.size();
	for(int i = 0; i < n; ++i){
		if(!used[i] && a >= p[i]){
			int new_a = (a - p[i]) * t[i];
			used[i] = true;
			path.push_back(i);
			dfs(new_a, used, p, t, path);
			path.pop_back();
			used[i] = false;
			progressed = true;
		}
	}
	
	if(!progressed){
		if((int)path.size() > cnt){
			cnt = path.size();
			best_path = path;
		}
	}
	
}

vector<int> max_coupons(int a, vector<int> p, vector<int> t){
	int n = p.size();
	vector<int> path(n);
	vector<bool> used(n);
	dfs(a, used, p, t, path);
	return best_path;
}

/*int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//freopen("input.in", "r", stdin);
	//freopen("input.out", "w", stdout);    
	vector<int> ans = max_coupons(13, {4, 500, 8, 14}, {1, 1, 1, 1});
	for(auto x : ans) cout<<x<<endl;	
    return 0;
}*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...