답안 #800956

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800956 2023-08-02T02:22:17 Z vjudge1 Sure Bet (CEOI17_sure) C++
100 / 100
79 ms 5180 KB
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define el '\n'
#define fi first
#define sc second
//#define int ll
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
//#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
//using namespace __gnu_pbds;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
const int N=1e5+11;
// find_by_order, order_of_key
int n;
ld a[N], b[N];
void sol()
{
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    sort(a, a+n);
    sort(b, b+n);
    reverse(a, a+n);
    reverse(b, b+n);
    int id=0;
    ld ans1=0, ans2=0, ans=0;
    for(int i=0;i<n;i++)
    {
        ans1 += a[i];
        while(id<n && min(ans1-id, ans2-i-1) < min(ans1-id-1, ans2+b[id]-i-1))
        {
            ans2 += b[id];
            id++;
        }
        ans = max(ans, min(ans1-id, ans2-i-1));
    }
    cout << fixed << setprecision(4) << ans;
}
signed main()
{
//    freopen("SUREBET.INP", "r", stdin);
//    freopen("SUREBET.OUT", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--)
    {
        sol();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 79 ms 4776 KB Output is correct
18 Correct 68 ms 4808 KB Output is correct
19 Correct 71 ms 4816 KB Output is correct
20 Correct 68 ms 4780 KB Output is correct
21 Correct 75 ms 5180 KB Output is correct
22 Correct 67 ms 4736 KB Output is correct
23 Correct 68 ms 4692 KB Output is correct
24 Correct 69 ms 4684 KB Output is correct
25 Correct 68 ms 4776 KB Output is correct
26 Correct 74 ms 5136 KB Output is correct