답안 #1085298

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1085298 2024-09-07T21:55:40 Z LeonidCuk Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 1116 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
vector<double>v1,v2,p1,p2,ans(100001);
double vidi(int n)
{
    double a=0;
    for(int i=0;i<=n;i++)
    {
        double b=min(p1[i],p2[n-i]);
        if(b>a)
        {
            a=b;
        }
    }
    return a-double(n);
}
int main()
{
    int n;
    double a,b,ans=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        v1.push_back(a);
        v2.push_back(b);
    }
    sort(v1.begin(),v1.end(),greater<double>());
    sort(v2.begin(),v2.end(),greater<double>());
    p1.push_back(0);
    p2.push_back(0);
    for(int i=0;i<n;i++)
    {
        p1.push_back(p1[i]+v1[i]);
        p2.push_back(p2[i]+v2[i]);
    }
    for(int i=0;i<=n;i++)
    {
        if(p1[n-i]<=p2[i])
        {
            continue;
        }
        double temp=min(p1[n-i],p2[i])-n,lt=0,rt=temp;
        int l=0,r=i;
        ans=max(temp,ans);
        while(l<r)
        {
            int m=(l+r)/2;
            temp=min(p1[n-i],p2[m])-(n-i)-m;
            if(temp<rt)
            {
                l=m+1;
                lt=temp;
            }
            else
            {
                r=m;
                rt=temp;
            }
            ans=max(temp,ans);
        }
    }
    for(int i=0;i<=n;i++)
    {
        if(p2[n-i]<=p1[i])
        {
            continue;
        }
        double temp=min(p2[n-i],p1[i])-n,lt=0,rt=temp;
        int l=0,r=i;
        ans=max(temp,ans);
        while(l<r)
        {
            int m=(l+r)/2;
            temp=min(p2[n-i],p1[m])-(n-i)-m;
            if(temp<rt)
            {
                l=m+1;
                lt=temp;
            }
            else
            {
                r=m;
                rt=temp;
            }
            ans=max(temp,ans);
        }
    }
    cout<<fixed<<setprecision(4)<<ans;
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:44:42: warning: variable 'lt' set but not used [-Wunused-but-set-variable]
   44 |         double temp=min(p1[n-i],p2[i])-n,lt=0,rt=temp;
      |                                          ^~
sure.cpp:70:42: warning: variable 'lt' set but not used [-Wunused-but-set-variable]
   70 |         double temp=min(p2[n-i],p1[i])-n,lt=0,rt=temp;
      |                                          ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1112 KB Output is correct
2 Incorrect 1 ms 1116 KB Output isn't correct
3 Halted 0 ms 0 KB -