Submission #201809

# Submission time Handle Problem Language Result Execution time Memory
201809 2020-02-12T05:23:05 Z abil Sure Bet (CEOI17_sure) C++14
0 / 100
5 ms 376 KB
#include <bits/stdc++.h>

#define fr first
#define sc second
#define pb push_back
#define all(s) s.begin(),s.end()
//#define int long long

using namespace std;

const int N = (1e6 + 12);
const int mod = (1e9 + 12);
const int inf = (1e9 + 12);

double a[N], b[N], pr[N];

bool cmp(double x, double y){
  return x >= y;
}

main()
{
  int n;
  scanf("%d", &n);
  for(int i = 1;i <= n; i++){
    cin >> a[i] >> b[i];
  }
  sort(a + 1,a + 1 + n, cmp);
  sort(b + 1,b + 1 + n, cmp);
  double ans = 0.0, sum = 0.0;
  for(int j = 1;j <= n; j++){
    pr[j] = pr[j - 1] + b[j];
  }
  for(int i = 1;i <= n; i++){
    sum += a[i];
    int l = 0, r = n;
    while(r - l > 1){
      int mid = (r + l) >> 1;
      if(pr[mid] - mid - i > sum - mid - i){
        r = mid;
      }
      else{
        l = mid;
      }
    }
    ans = max(ans, min(pr[r] - r - i, sum - r - i));
    ans = max(ans, min(pr[l] - l - i, sum - l - i));
  }
  cout << fixed << setprecision(5) << ans;
}


Compilation message

sure.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
sure.cpp: In function 'int main()':
sure.cpp:24:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -