제출 #654732

#제출 시각아이디문제언어결과실행 시간메모리
654732pauloamedSure Bet (CEOI17_sure)C++14
100 / 100
94 ms6040 KiB
#include<bits/stdc++.h> using namespace std; #define ld double vector<ld> sa, sb; ld ternary_search(int lo, int hi, ld a, int b) { auto f = [&](int j){ return min(sb[j], a) - (b + j + 1); }; while (hi - lo > 1){ int mid = (hi + lo)>>1; if (f(mid) > f(mid + 1)) hi = mid; else lo = mid; } return f(lo + 1); } int32_t main(){ cin.tie(NULL)->sync_with_stdio(false); int n; cin >> n; vector<ld> a, b; for(int i = 0; i < n; ++i){ ld x, y; cin >> x >> y; a.push_back(x); b.push_back(y); } sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); for(int i = 0; i < n; ++i){ sa.push_back(a[i]); sb.push_back(b[i]); if(i){ sa[i] += sa[i - 1]; sb[i] += sb[i - 1]; } } for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ ld x = min(sa[i], sb[j]); int y = i + j + 2; } } ld ans = 0; for(int i = 0; i < n; ++i){ ans = max(ans, ternary_search(-1, n, sa[i], (i + 1))); } cout << setprecision(4) << fixed << ans << "\n"; }

컴파일 시 표준 에러 (stderr) 메시지

sure.cpp: In function 'int32_t main()':
sure.cpp:48:10: warning: unused variable 'x' [-Wunused-variable]
   48 |       ld x = min(sa[i], sb[j]);
      |          ^
sure.cpp:49:11: warning: unused variable 'y' [-Wunused-variable]
   49 |       int y = i + j + 2;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...