| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 536180 | drkarlicio2107 | Hiring (IOI09_hiring) | C++14 | 710 ms | 65536 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std; vector < pair < pair <double, int>, pair <double, double> > > k; map <double, int> saz; vector <double> qi; map <int, double> ob; double min_w;
vector < pair < double, int > > sol;
const int OFF = (1 << 18);
double tour[2*OFF];
void update(int x, double v) {
x+=OFF;
tour[x]=v;
x/=2;
while (x) {
tour[x]=tour[x*2]+tour[x*2+1];
x/=2;
}
return;
}
int query(int lo=0, int hi=OFF-1, int x=1, double now=0) {
if (lo==hi) return x-OFF;
int mid=(lo+hi)/2;
double le=tour [x*2];
double de=tour [x*2+1];
if (le+now>min_w) return query(lo, mid, x*2, now);
else return query(mid+1, hi, x*2+1, le+now);
}
int fen[OFF+10];
void dodaj(int a, int v){
for (a; a<OFF+10; a+= a & -a) fen[a]+=v;
}
int ispis(int a){
if (a==0) return 0;
int izlaz=0;
for (a; a>0; a-= a & -a) izlaz+=fen[a];
return izlaz;
}
int main(){
int n; double w; cin >> n >> w;
for (int i=0; i<n; i++){
double s, q; cin >> s >> q;
double x=s/q;
k.push_back({{x, i}, {s, q}});
qi.push_back(q);
}
sort (qi.begin (), qi.end ());
sort (k.begin (), k.end ());
int ind=1;
for (int i=0; i<qi.size(); i++){
//cout << qi [i] << endl;
saz [qi[i]]=ind; ob [ind]=qi[i]; ind++;
}
int max_ans=-1, res;
for (int i=0; i<n; i++){
double x=k[i].first.first;
min_w=w/x;
int ind=saz [k[i].second.second];
//cout << x << " " << min_w << " " << ind << endl;
int val=k[i].second.second;
dodaj (ind, 1);
update (ind, val);
int gr=query ();
if (ispis (gr-1)>max_ans){
max_ans=ispis (gr-1); res=i;
}
}
//cout << res << endl;
for (int i=0; i<res+1; i++){
int ind1=k[i].first.second;
int val=k[i].second.second;
sol.push_back((make_pair(val, ind1)));
}
sort (sol.begin(), sol.end());
cout << max_ans << endl;
for (int i=0; i<max_ans; i++) cout << sol [i].second+1 << endl;
}컴파일 시 표준 에러 (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... | ||||
