| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1308100 | MunkhErdene | 축제 (IOI25_festival) | C++17 | 0 ms | 0 KiB |
#include "festival.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define _ << " " <<
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ull unsigned long long
#define lll __int128
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define BlueCrowner ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll naim = 1e9;
const ll max_bit = 60;
const ull tom = ULLONG_MAX;
const ll MAXN = 100005;
const ll LOG = 20;
const ll NAIM = 1e18;
const ll N = 2e6 + 5;
std::vector<int> max_coupons(int A, std::vector<int> P, std::vector<int> T) {
ll a = A;
vector<ll> p(all(P)), t(all(T));
ll n = p.size();
vector<ll> ord(n);
iota(all(ord), 0);
sort(all(ord), [&](ll i, ll j) {
ll x = p[i], y = p[j], t1 = t[i], t2 = t[j];
if(t1 == t2) return x < y;
return x * t1 * t2 + y * t2 < y * t1 * t2 + x * t1;
});
vector<int> res;
for(auto &i : ord) {
if(a >= p[i]) {
res.pb(i);
a -= p[i];
a *= t[i];
}
}
return res;
}
int main() {
BlueCrowner;
int N, A;
cin >> N >> A;
vector<int> P(N), T(N);
for (int i = 0; i < N; i++) cin >> P[i];
for (int i = 0; i < N; i++) cin >> T[i];
vector<int> R = max_coupons(A, P, T);
int S = R.size();
cout << S << '\n';
for (int i = 0; i < S; i++)
cout << (i == 0 ? "" : " ") << R[i];
cout << '\n';
}
