| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1326212 | hahaha | 축제 (IOI25_festival) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define f first
#define int long long
#define s second
std::vector<int> max_coupons(int A, std::vector<int> P,
std::vector<int> T){
int n=P.size();
pair<int,int> t1[n],t2[n];
int k1=-1,k2=-1;
for(int i=0; i<n; i++){
if(T[i]==2){
t2[++k2].f=P[i];
t2[k2].s=i;}
else{
t1[++k1].f=P[i];
t1[k1].s=i;}
}
k1++; k2++;
sort(t1, t1+k1);
sort(t2, t2+k2);
for(int i=1; i<k1; i++) t1[i].f+=t1[i-1].f;
int c=A;
int m1=0,m2=0;
for(int i=0; i<=k2&&c>-1; i++){
int l=0, r=k1-1;
int x;
while(l<=r){
x=l+(r-l)/2;
if(t1[x].f<=c&&t1[x+1].f>c) l=r+1;
else if(t1[x].f<c)
l=x+1;
else
r=x-1;
}
if((m1+m2)<i+x+1){
m1=x+1;
m2=i;
}
c=(c-t2[i].f)*2;
}
vector<int> R;
for( int i=0; i<m2; i++)
R.push_back(t2[i].s);
for(int i=0; i<m1; i++)
R.push_back(t1[i].s);
return R;
}
