제출 #13940

#제출 시각아이디문제언어결과실행 시간메모리
13940imsifileBe Two Bees (OJUZ10_b2b)C++98
33 / 100
57 ms7344 KiB
#include<stdio.h> #include<algorithm> using namespace std; struct a1 { long long h, t; int ix; bool operator< (const a1& c) const { if(h!=c.h)return h>c.h; return t<c.t; } }ba1[100100]; struct a2 { long long h, t; int ix; bool operator< (const a2& c) const { if(t!=c.t)return t<c.t; return h>c.h; } }ba2[100100]; int n, da, db; long long sum, hi[100100], ti[100100]; double dap; double pick(int a, int b){ double honey=sum-hi[a]-hi[b]; double til=(1.0/ti[a])+(1.0/ti[b]); return honey/til; } int main(){ int i, j; scanf("%d", &n); for(i=0; i<n; i++)scanf("%lld", &hi[i]), sum+=hi[i]; for(i=0; i<n; i++)scanf("%lld", &ti[i]); for(i=0; i<n; i++){ ba1[i].ix=ba2[i].ix=i; ba1[i].h=ba2[i].h=hi[i]; ba1[i].t=ba2[i].t=ti[i]; } sort(ba1,ba1+n); sort(ba2,ba2+n); da=0, db=1, dap=pick(0,1); for(i=0; i<10; i++){ for(j=0; j<10; j++){ if(ba1[i].ix != ba2[j].ix){ double gap=pick(ba1[i].ix, ba2[j].ix); if(dap>gap)dap=gap, da=ba1[i].ix, db=ba2[j].ix; } if(ba1[i].ix != ba1[j].ix){ double gap=pick(ba1[i].ix, ba1[j].ix); if(dap>gap)dap=gap, da=ba1[i].ix, db=ba1[j].ix; } if(ba2[i].ix != ba2[j].ix){ double gap=pick(ba2[i].ix, ba2[j].ix); if(dap>gap)dap=gap, da=ba2[i].ix, db=ba2[j].ix; } } } if(da>db)swap(da,db); printf("%d %d", da+1, db+1); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...