제출 #13950

#제출 시각아이디문제언어결과실행 시간메모리
13950gs14004Be Two Bees (OJUZ10_b2b)C++14
61 / 100
156 ms2644 KiB
#include <cstdio> #include <algorithm> #include <vector> using namespace std; int n; int h[100005], u[100005]; long long S; double tmp[100005]; int r1, r2; bool trial(double t){ for (int i=0; i<n; i++) { tmp[i] = h[i] + t / u[i]; } double ret = 0; auto *pt = max_element(tmp,tmp+n); ret += *pt; r1 = (int)(pt - tmp) + 1; *pt = -1e18; pt = max_element(tmp,tmp+n); ret += *pt; r2 = (int)(pt - tmp) + 1; return ret >= S; } int main(){ scanf("%d",&n); for (int i=0; i<n; i++) { scanf("%d",&h[i]); S += h[i]; } for (int i=0; i<n; i++) { scanf("%d",&u[i]); } double s = 0, e = 1e11; for (int i=0; i<100; i++) { double m = (s+e)/2; if(trial(m)) e = m; else s = m; } printf("%d %d",min(r1,r2),max(r1,r2)); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...