# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
621058 | 2022-08-03T11:36:15 Z | prarie | Sure Bet (CEOI17_sure) | C++14 | 67 ms | 3612 KB |
#include <bits/stdc++.h> #define fastio ios_base::sync_with_stdio(0), cin.tie(0) #define endl '\n' #define fi first #define se second #define sz(v) (int)(v).size() #define all(v) (v).begin(), (v).end() #define compress(v) sort(all(v)), (v).erase(unique(all((v))), v.end()) #define pb push_back #define eb emplace_back using namespace std; using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using ld = long double; template <typename T> inline void Mx(T &x, T y) { x < y && (x = y); } template <typename T> inline void Mn(T &x, T y) { x > y && (x = y); } int main() { int N; scanf("%d", &N); vector<double> A(N), B(N); for (int i = 0; i < N; i++) { scanf("%lf %lf", &A[i], &B[i]); } sort(all(A)); reverse(all(A)); sort(all(B)); reverse(all(B)); double ans = 0; double Asum = 0, Bsum = 0; int Aptr = 0, Bptr = 0; for (int x = 1; x <= 2 * N; x++) { if (Aptr == N) { Bsum += B[Bptr++]; } else if (Bptr == N) { Asum += A[Aptr++]; } else { if (Asum == Bsum) { if (A[Aptr] < B[Bptr]) { Bsum += B[Bptr++]; } else { Asum += A[Aptr++]; } } else if (Asum > Bsum) { Bsum += B[Bptr++]; } else { Asum += A[Aptr++]; } } ans = max(ans, min(Asum, Bsum) - x); } printf("%.4lf", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 300 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 2 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 308 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 0 ms | 300 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 2 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 308 KB | Output is correct |
17 | Correct | 61 ms | 3120 KB | Output is correct |
18 | Correct | 61 ms | 3148 KB | Output is correct |
19 | Correct | 59 ms | 3252 KB | Output is correct |
20 | Correct | 57 ms | 3268 KB | Output is correct |
21 | Correct | 63 ms | 3612 KB | Output is correct |
22 | Correct | 59 ms | 3232 KB | Output is correct |
23 | Correct | 64 ms | 3232 KB | Output is correct |
24 | Correct | 59 ms | 3128 KB | Output is correct |
25 | Correct | 66 ms | 3240 KB | Output is correct |
26 | Correct | 67 ms | 3520 KB | Output is correct |