Submission #842596

#TimeUsernameProblemLanguageResultExecution timeMemory
842596vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
76 ms11476 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; double pre_a[N]; double pre_b[N]; double a[N] , b[N] , mx[N]; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen("solve.inp" , "r")) { freopen("solve.inp" , "r" , stdin); freopen("solve.out" , "w" , stdout); } int n; cin >> n; for(int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } sort(a , a + n , greater <double> ()); sort(b , b + n , greater <double> ()); for(int i = 1; i <= n; i++) { pre_a[i] = pre_a[i - 1] + a[i - 1] - 1; pre_b[i] = pre_b[i - 1] + b[i - 1] - 1; } for(int i = 1; i <= n; i++) { mx[i] = max(mx[i - 1] , pre_b[i]); } double l = 0.0; double r = INT_MAX; for(int i = 0; i < 100; i++) { double mid = (l + r) / 2; bool check = false; for(int j = 0; j <= n; j++) { int x = min(n * 1.0 , (pre_a[j] - mid)); if(x >= 0 && mx[x] >= j + mid) { check = (check | x); } } if(check == true) l = mid; else r = mid; } cout << setprecision(4) << fixed << r << '\n'; return 0x0; }

Compilation message (stderr)

sure.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      | ^~~~
sure.cpp: In function 'int main()':
sure.cpp:14:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   freopen("solve.inp" , "r" , stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:15:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   freopen("solve.out" , "w" , stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...