# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1027367 | 2024-07-19T04:59:38 Z | vjudge1 | Sure Bet (CEOI17_sure) | C++17 | 50 ms | 8284 KB |
#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define int long long // #define double long double #define endl '\n' #define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define setmin(x, y) x = min((x), (y)) #define setmax(x, y) x = max((x), (y)) #define sqr(x) ((x) * (x)) #define fi first #define se second // mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count()); // int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);} const int NM = 1e6 + 5; const int mod = 1e6 + 3; const int inf = 1e9 + 1; int n; double a[NM], b[NM], ans, cur, A, B; signed main() { if (fopen("in.txt", "r")) { freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); } fastIO cin >> n; for (int i = 1; i <= n; i++) cin >> a[i] >> b[i]; sort(a + 1, a + 1 + n, greater<double>()); sort(b + 1, b + 1 + n, greater<double>()); int pa = 0, pb = 0; while (pa < n || pb < n) { if (pa == n) { ++pb; B += b[pb]; } else if (pb == n) { ++pa; A += a[pa]; } else if (A <= B) { ++pa; A += a[pa]; } else { ++pb; B += b[pb]; } setmax(ans, min(A, B) - pa - pb); } cout << fixed << setprecision(4) << ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2392 KB | Output is correct |
3 | Correct | 1 ms | 2392 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 0 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2392 KB | Output is correct |
3 | Correct | 1 ms | 2392 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 0 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2564 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 0 ms | 2396 KB | Output is correct |
12 | Correct | 2 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2392 KB | Output is correct |
3 | Correct | 1 ms | 2392 KB | Output is correct |
4 | Correct | 0 ms | 2396 KB | Output is correct |
5 | Correct | 0 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2396 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 1 ms | 2564 KB | Output is correct |
10 | Correct | 1 ms | 2396 KB | Output is correct |
11 | Correct | 0 ms | 2396 KB | Output is correct |
12 | Correct | 2 ms | 2396 KB | Output is correct |
13 | Correct | 1 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 1 ms | 2396 KB | Output is correct |
16 | Correct | 1 ms | 2396 KB | Output is correct |
17 | Correct | 47 ms | 8028 KB | Output is correct |
18 | Correct | 47 ms | 8280 KB | Output is correct |
19 | Correct | 47 ms | 8016 KB | Output is correct |
20 | Correct | 48 ms | 8044 KB | Output is correct |
21 | Correct | 50 ms | 8276 KB | Output is correct |
22 | Correct | 46 ms | 7916 KB | Output is correct |
23 | Correct | 48 ms | 8024 KB | Output is correct |
24 | Correct | 47 ms | 8028 KB | Output is correct |
25 | Correct | 49 ms | 8028 KB | Output is correct |
26 | Correct | 50 ms | 8284 KB | Output is correct |