# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
491111 | 2021-11-30T15:01:27 Z | hollwo_pelw | Sure Bet (CEOI17_sure) | C++17 | 92 ms | 3600 KB |
/* // is short or still long ??? hollwo_pelw's template(short) // Note : -Dhollwo_pelw_local */ #include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/trie_policy.hpp> // #include <ext/rope> using namespace std; // using namespace __gnu_pbds; // using namespace __gnu_cxx; void FAST_IO(string filein = "", string fileout = "", string fileerr = ""){ if (fopen(filein.c_str(), "r")){ freopen(filein.c_str(), "r", stdin); freopen(fileout.c_str(), "w", stdout); #ifdef hollwo_pelw_local freopen(fileerr.c_str(), "w", stderr); #endif } cin.tie(0), cout.tie(0) -> sync_with_stdio(0); } void Hollwo_Pelw(); signed main(){ #ifdef hollwo_pelw_local FAST_IO("input.inp", "output.out", "error.err"); auto start = chrono::steady_clock::now(); #else FAST_IO("D.inp", "D.out"); #endif int testcases = 1; // cin >> testcases; for (int test = 1; test <= testcases; test++){ // cout << "Case #" << test << ": "; Hollwo_Pelw(); } #ifdef hollwo_pelw_local auto end = chrono::steady_clock::now(); cout << "\nExcution time : " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl; #endif return 0; } const int N = 1e5 + 5; int n; double a[N], b[N], res = 0; void Hollwo_Pelw() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; sort(a + 1, a + n + 1, greater<double>()); sort(b + 1, b + n + 1, greater<double>()); double sa = 0, sb = 0, cur = 0; for (int i = 0, j = 0; i <= n; i++) { sa += a[i]; while (j < n && sb + b[j + 1] < sa) { sb += b[++ j]; cur = max(cur, sb - j); } res = max(res, cur - i); if (j < n) res = max(res, sa - i - j - 1); } cout << fixed << setprecision(4) << res; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 316 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 316 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 2 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 316 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 0 ms | 204 KB | Output is correct |
12 | Correct | 2 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 1 ms | 332 KB | Output is correct |
15 | Correct | 1 ms | 332 KB | Output is correct |
16 | Correct | 1 ms | 332 KB | Output is correct |
17 | Correct | 68 ms | 3228 KB | Output is correct |
18 | Correct | 67 ms | 3204 KB | Output is correct |
19 | Correct | 71 ms | 3148 KB | Output is correct |
20 | Correct | 70 ms | 3168 KB | Output is correct |
21 | Correct | 87 ms | 3516 KB | Output is correct |
22 | Correct | 67 ms | 3228 KB | Output is correct |
23 | Correct | 68 ms | 3236 KB | Output is correct |
24 | Correct | 77 ms | 3112 KB | Output is correct |
25 | Correct | 92 ms | 3228 KB | Output is correct |
26 | Correct | 82 ms | 3600 KB | Output is correct |