Submission #846548

# Submission time Handle Problem Language Result Execution time Memory
846548 2023-09-07T21:08:49 Z QwertyPi Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

int32_t main(){
  int n; cin >> n;
  vector<double> a, b;
  
  for(int i = 0; i < n; i++){
    int v; cin >> v; a.push_back(v);
  }
  
  for(int i = 0; i < n; i++){
    int v; cin >> v; b.push_back(v);
  }
  
  sort(a.begin(), a.end(), [](int x, int y){ return x > y; });
  sort(b.begin(), b.end(), [](int x, int y){ return x > y; });
  
  vector<double> sa(n + 1), sb(n + 1);
  for(int i = 0; i < n; i++) sa[i + 1] = sa[i] + a[i];
  for(int i = 0; i < n; i++) sb[i + 1] = sb[i] + b[i];
  
  int L = 0, R = 0;
  double ans = 0;
  while(L < n || R < n){
    if(R == n || L < n && sa[L] < sb[R]) L++;
    else R++;
    ans = max(ans, min(sa[L], sb[R]) - (L + R));
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Compilation message

sure.cpp: In function 'int32_t main()':
sure.cpp:27:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   27 |     if(R == n || L < n && sa[L] < sb[R]) L++;
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -