# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1253911 | chr34 | Festival (IOI25_festival) | C++20 | 0 ms | 0 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;
vector<int> max_coupons(int a, vector<int> p, vector<int> t) {
int n = p.size();
vector<bool> used(n, false);
vector<int> ans;
for(int step = 0; step < n; ++step){
int best_idx = -1;
for(int i = 0; i < n; ++i){
if(!used[i] && a >= p[i]){
if(best_idx == -1) best_idx = i;
else{
// choose between higher t or same t and cheaper price
if(t[i] > t[best_idx]) best_idx = i;
else if(t[i] == t[best_idx] && p[i] < p[best_idx]) best_idx = i;
}
}
}
if(best_idx == -1) break;
used[best_idx] = true;
a = (a - p[best_idx]) * t[best_idx];
ans.push_back(best_idx);
}
return ans;
}
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;
}