# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1082049 | Dennis_Jason | Hiring (IOI09_hiring) | C++14 | 608 ms | 54104 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define NMAX 2005
#define pb push_back
#define eb emplace_back
#define MOD 100003
#define nl '\n'
#define LLONG_MAX 9223372036854775807
#define pii pair<double,double>
#define tpl tuple<int,int,int>
//#pragma GCC optimize("O3")
#define INF 2147483647
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
/*
*
*
================DEMONSTRATION===================
=====================END========================
*/
struct pers{
double r,s,q;
int ind;
};
int n,budget;
vector<pers>v;
int ans,ind;
double cost;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>budget;
v.resize(n+1);
for(int i=1;i<=n;++i)
{
cin>>v[i].s>>v[i].q;
v[i].r=(v[i].s/v[i].q);
v[i].ind=i;
}
auto cmp=[&](pers a,pers b)
{
return a.r<b.r;
};
sort(v.begin()+1,v.end(),cmp);
double total=0;
priority_queue<double,vector<double>>pq;
for(int i=1;i<=n;++i)
{
pq.push(v[i].q);
total+=v[i].q;
double maxi=budget/v[i].r;
while(total>maxi)
{
total-=pq.top();
pq.pop();
}
int nr=pq.size();
double aux=total*v[i].r;
if(nr>ans ||(nr==ans && aux<cost))
{
ans=nr;
cost=aux;
ind=i;
}
}
priority_queue<pii,vector<pii>>heap;
total=0;
map<int,int>mp;
for(int i=1;i<=ind;++i)
{
heap.push({v[i].q,v[i].ind});
total+=v[i].q;
mp[v[i].ind]=1;
}
double maxi=budget/v[ind].r;
while(total>maxi)
{
auto x=heap.top();
heap.pop();
total-=x.first;
mp[x.second]=0;
}
cout<<ans<<nl;
for(int i=1;i<=n;++i)
{
if(mp[i])
cout<<i<<nl;
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |