| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1325967 | somefolk | 축제 (IOI25_festival) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
struct El {
int p, idx;
};
vector<int> max_coupons(int a, vector<int> p, vector<int> t){
int n = (int)p.size();
vector<El> ones, twos;
for(int i = 0; i < n; i++){
if(t[i] == 1) ones.push_back({p[i], i});
else twos.push_back({p[i], i});
}
sort(ones.begin(), ones.end(), [&](auto l, auto r){ return l.p < r.p; });
sort(twos.begin(), twos.end(), [&](auto l, auto r){ return l.p < r.p; });
int curr = a, pos1 = -1, pos2 = -1;
for(int i = 0; i < (int)twos.size(); i++){
curr = 2*(curr - twos[i].p);
if(curr < 0) break;
int curr2 = curr;
for(int j = 0; j < (int)ones.size(); j++){
if(curr2 - ones[j].p < 0) break;
curr2 -= ones[j].p;
if(i + j + 2 > pos1 + pos2 + 2){
pos2 = i;
pos1 = j;
}
}
}
vector<int> sol;
for(int i = 0; i <= pos2; i++) sol.push_back(twos[i].idx);
for(int i = 0; i <= pos1; i++) sol.push_back(ones[i].idx);
return sol;
}
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(nullptr);
vector<int> ans = max_coupons(13, {4, 6, 8, 14}, {1, 1, 2, 2});
for(auto &i : ans) cout << i << " ";
return 0;
}
