Submission #938496

# Submission time Handle Problem Language Result Execution time Memory
938496 2024-03-05T08:10:46 Z iskhakkutbilim Sure Bet (CEOI17_sure) C++17
100 / 100
121 ms 5212 KB
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define int long long
const int N = 2e5;
const int mod = 1e9 + 7;


signed main(){
   
   int n; cin >> n;
   vector<long double> a(n), b(n);
	for(int i = 0;i < n; i++){
		cin >> a[i] >> b[i];
	}
   long double ans = 0.0;
   sort(a.rbegin(), a.rend());
   sort(b.rbegin(), b.rend());
   
   long double s = 0, s1 = 0;
   int cnt = 0, i =0 ;
   for(int j = 0;j < n; j++){
	   s1+= b[j];
	   cnt++;
	   ans = max(ans, min(s, s1) - cnt);
	   while(i < n && s - cnt <= s1-cnt){
		   s+= a[i];
		   i++, cnt++;
		   ans = max(ans, min(s, s1) - cnt);
	   }
   }
  
   printf("%.4lf", (double)ans);
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 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 1 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 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 1 ms 348 KB Output is correct
11 Correct 1 ms 452 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 110 ms 4824 KB Output is correct
18 Correct 111 ms 4704 KB Output is correct
19 Correct 106 ms 4692 KB Output is correct
20 Correct 107 ms 4952 KB Output is correct
21 Correct 119 ms 5212 KB Output is correct
22 Correct 104 ms 4716 KB Output is correct
23 Correct 104 ms 4692 KB Output is correct
24 Correct 120 ms 4828 KB Output is correct
25 Correct 104 ms 4936 KB Output is correct
26 Correct 121 ms 5088 KB Output is correct