Submission #878646

# Submission time Handle Problem Language Result Execution time Memory
878646 2023-11-25T03:05:16 Z Muhammad_Aneeq Sure Bet (CEOI17_sure) C++17
100 / 100
130 ms 5400 KB
/*
بسم الله الرحمن الرحيم
Author:
                          (:Muhammad Aneeq:)
*/
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ld long double
inline void solve()
{
  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.begin(), a.end());
  reverse(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(b.begin(), b.end());
  ld ans=0;
  int i=0,j=0;
  ld sa=0,sb=0;
  while (i<n||j<n)
  {
    if (i==n||sa>sb)
      sb+=b[j++];
    else
      sa+=a[i++];
    ans=max(ans,min(sb-(i+j),sa-(i+j)));
  }
  printf("%.4lf\n",(double)ans);
}
int main()
{
  // ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
        solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 460 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 104 ms 3708 KB Output is correct
18 Correct 108 ms 5036 KB Output is correct
19 Correct 105 ms 5036 KB Output is correct
20 Correct 127 ms 5040 KB Output is correct
21 Correct 116 ms 5292 KB Output is correct
22 Correct 104 ms 5292 KB Output is correct
23 Correct 104 ms 4920 KB Output is correct
24 Correct 114 ms 4980 KB Output is correct
25 Correct 130 ms 5000 KB Output is correct
26 Correct 119 ms 5400 KB Output is correct