답안 #422696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
422696 2021-06-10T10:34:13 Z ak2006 Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
const ll mod = 1e9 + 7,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void setIO()
{
    fast;

}
int main()
{
    setIO();
    int n;
    cin>>n;
    vector<double>a(n),b(n);
    vector<double>sums(n + 1);
    for (int i = 0;i<n;i++)cin>>a[i]>>b[i],a[i]--,b[i]--;
    sort(a.begin(),a.end()),sort(b.begin(),b.end());
    for (int i = n - 1;i>=0;i--)sums[i] = b[i] + sums[i + 1];
    double sum = 0;
    double out = 0;
    for (int i = n - 1;i>=0;i--){
        int na = n - i;
        sum += a[i];
        int l = 0,r = n - 1,ans = -1;
        while (l <= r){
            int mid = (l + r)/2;
            if (sums[mid] + n - mid >= sum + na){
                ans = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
        if (ans == -1){
            double val = sums[0] - na;
            out = max(out,val);
        }
        else {
            double val = sum - (n - ans);
            out = max(out,val);
        }
    }
    printf("%.4lf\n", out);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -